-
Notifications
You must be signed in to change notification settings - Fork 2.1k
/
build.gradle
executable file
·294 lines (267 loc) · 11.7 KB
/
build.gradle
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
plugins {
id "com.github.hierynomus.license" version "0.14.0"
id 'com.jfrog.artifactory' version '4.10.0'
}
apply plugin: 'com.android.library'
apply plugin: 'checkstyle'
apply plugin: 'com.jfrog.bintray'
apply plugin: 'com.github.dcendents.android-maven'
apply from: 'buildSrc/jcenter.gradle'
apply from: 'buildSrc/unstripped.gradle'
apply from: 'buildSrc/checkStyle.gradle'
apply from: 'buildSrc/download_jsc.gradle'
apply from: 'buildSrc/packageName.gradle'
apply from: 'buildSrc/asan.gradle'
version = project.weexVersion
group = project.groupId
//Check version, the version must have 4 sections. The leading three section must be number, and the last section is odd number with or without suffix string.
if (!project.hasProperty('ignoreVersionCheck') || !project.getProperty('ignoreVersionCheck').equals("true")) {
version.tokenize('.').eachWithIndex { it, i ->
if (i < 3) {
assert it.isNumber() : "Please use semantic versioning witch 4 sections, you are using ${${i} + 1} section instead."
} else if (i == 3) {
it.split("[-_]").toList().eachWithIndex { inner_it, inner_i ->
if (inner_i == 0) {
assert inner_it.isNumber() && inner_it.toInteger() % 2 : "The 4th dight in the versioning number must be a odd number, and it is ${inner_it} currently."
} else {
assert !inner_it.isNumber() : "The suffix of the versioning number is not allowed to contain any number, and it is ${inner_it} currently."
}
}.size == 4
} else {
assert false: "Please use semantic versioning witch 4 sections, you are using ${${i} + 1} section instead."
}
}
}
android {
compileSdkVersion project.compileSdkVersion
resourcePrefix "weex"
useLibrary 'org.apache.http.legacy'
if(project.hasProperty('removeSharedLib') && "true".equals(project.getProperty('removeSharedLib'))) {
packagingOptions {
exclude 'lib/armeabi-v7a/libc++_shared.so'
exclude 'lib/arm64-v8a/libc++_shared.so'
exclude 'lib/x86/libc++_shared.so'
exclude 'lib/x86_64/libc++_shared.so'
}
}
copy {
from '../../pre-build'
into new File(projectDir,"assets")
include 'native-bundle-main.js'
rename('native-bundle-main.js','main.js')
}
def line
new File(projectDir,"assets/main.js").withReader { line = it.readLine() }
def m = line =~ /[A-Z\s]+\s+([0-9\.]+),\s+Build\s+[0-9]+/;
def jsfmVersion // = m[0][1]
println jsfmVersion
copy {
from '../../pre-build'
into new File(projectDir,"assets")
include 'weex-main-jsfm.js'
rename('weex-main-jsfm.js','weex-main-jsfm.js')
}
copy {
from '../../pre-build'
into new File(projectDir,"assets")
include 'weex-rax-api.js'
}
def ndkversion = 16;
def api_level = "";
def compile_tool = "clang";
def cxx_stl = "c++_shared";
if (ndkversion < 16) {
api_level = "android-14";
} else {
api_level = "android-16";
}
def android_project_dir = projectDir
def buildRuntimeApi = project.hasProperty('buildRuntimeApi') ? project.property('buildRuntimeApi').toBoolean() : true
def jsInterpolatorName = project.hasProperty('JSInterpolatorName') ? project.property('JSInterpolatorName') : 'jsc'
def initJSCPrivateApi = false
if (buildRuntimeApi){
initJSCPrivateApi = jsInterpolatorName =="JavaScriptCore"
}
defaultConfig {
buildConfigField "String", "buildJavascriptFrameworkVersion", "\"${jsfmVersion}\""
buildConfigField "String", "buildVersion", "\"${version}\""
buildConfigField "String", "JSInterpolatorName", "\"${jsInterpolatorName}\""
minSdkVersion project.minSdkVersion
targetSdkVersion project.targetSdkVersion
multiDexEnabled true
versionCode 1
versionName project.version
ndk {
if(!project.hasProperty('supportArmeabi-v7a') || "false" != project.getProperty('supportArmeabi-v7a')){
abiFilters 'armeabi-v7a'
}
if(!project.hasProperty('supportArm64-v8a') || "false" != project.getProperty('supportArm64-v8a')){
abiFilters 'arm64-v8a'
}
if(!project.hasProperty('supportX86') || "false" != project.getProperty('supportX86')){
abiFilters 'x86'
}
if(!project.hasProperty('supportX86_64') || "false" != project.getProperty('supportX86_64')){
abiFilters 'x86_64'
}
}
externalNativeBuild {
cmake {
arguments '-DANDROID_PLATFORM=' + "${api_level}",
'-DANDROID_TOOLCHAIN=' + "${compile_tool}",
'-DANDROID_STL=' + "${cxx_stl}",
'-DCMAKE_BUILD_TYPE=Release',
'-DANDROID_PROJECT_DIR=' + "${android_project_dir}",
'-DENABLE_ASAN=false'
if(buildRuntimeApi){
arguments '-DBUILD_RUNTIME_API='+"${buildRuntimeApi}"
if (initJSCPrivateApi){
arguments '-DINIT_JSC_PRIVATE_API='+"${initJSCPrivateApi}"
}
}
if(project.hasProperty('enableASan') && "true" == project.getProperty('enableASan')) {
cppFlags "-fsanitize=address -fno-omit-frame-pointer"
}
}
}
}
buildTypes {
release {
minifyEnabled false
buildConfigField "boolean", "ENABLE_TRACE", "false"
proguardFiles getDefaultProguardFile('proguard-android.txt'), useApachePackageName ? 'proguard-rules.pro' : 'proguard-rules-legacy.pro'
consumerProguardFiles useApachePackageName ? 'proguard-rules.pro' : 'proguard-rules-legacy.pro'
}
debug {
buildConfigField "boolean", "ENABLE_TRACE", "true"
jniDebuggable true
debuggable true
testCoverageEnabled disableCov.toBoolean()
consumerProguardFiles 'proguard-rules.pro'
}
apacheRelease{
initWith release
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
consumerProguardFiles 'proguard-rules.pro'
}
legacyRelease{
initWith release
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules-legacy.pro'
consumerProguardFiles 'proguard-rules-legacy.pro'
}
}
externalNativeBuild {
cmake {
if(project.useApachePackageName) {
path '../../weex_core/CMakeLists.txt'
}
else{
copy{
from new File('../../weex_core/CMakeLists.txt')
into new File('src/legacyRelease/cpp')
}
path 'src/legacyRelease/cpp/CMakeLists.txt'
}
}
}
sourceSets {
main.assets.srcDirs = ['assets']
apacheRelease.java.srcDirs = ['src/main/java']
apacheRelease.manifest.srcFile(new File('src/main/AndroidManifest.xml'))
legacyRelease.java.srcDirs = ['src/legacyRelease/java']
legacyRelease.manifest.srcFile(new File('src/legacyRelease/AndroidManifest.xml'))
if(!project.useApachePackageName){
main.java.srcDirs = ['src/legacyRelease/java']
main.manifest.srcFile(new File('src/legacyRelease/AndroidManifest.xml'))
}
if(project.unbundlingJSC){
main.jniLibs.srcDirs = []
}
}
compileOptions.encoding = "UTF-8"
lintOptions {
abortOnError false
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}
testOptions {
unitTests.all {
maxHeapSize = "1024m"
jvmArgs += ['-XX:-UseSplitVerifier', '-noverify','-Xverify:none']/* fix VerifyError */
}
}
}
dependencies {
//noinspection GradleDependency
compileOnly "com.android.support:recyclerview-v7:${project.supportLibVersion}"
//noinspection GradleDependency
compileOnly "com.android.support:support-v4:${project.supportLibVersion}"
//noinspection GradleDependency
compileOnly "com.android.support:appcompat-v7:${project.supportLibVersion}"
compileOnly "com.alibaba:fastjson:${project.fastjsonLibVersion}"
testImplementation "com.alibaba:fastjson:${project.fastjsonLibVersion}"
testImplementation 'junit:junit:4.12'
testImplementation 'org.hamcrest:hamcrest-core:1.3'
testImplementation 'org.javassist:javassist:3.20.0-GA'
testImplementation 'org.mockito:mockito-core:1.10.19'
//noinspection GradleDependency
testImplementation 'org.objenesis:objenesis:2.1'
testImplementation 'org.powermock:powermock-core:1.6.4'
testImplementation 'org.powermock:powermock-api-mockito:1.6.4'
testImplementation 'org.powermock:powermock-module-junit4-common:1.6.4'
testImplementation 'org.powermock:powermock-module-junit4:1.6.4'
testImplementation 'org.powermock:powermock-module-junit4-legacy:1.6.4'
testImplementation 'org.powermock:powermock-module-testng:1.6.4'
testImplementation 'org.powermock:powermock-classloading-xstream:1.6.4'
testImplementation "org.powermock:powermock-module-junit4-rule:1.6.4"
testImplementation 'org.robolectric:robolectric:3.3.2'
testImplementation "org.robolectric:shadows-httpclient:3.3.2"
testImplementation 'org.json:json:20160212'
}
license {
header = file('../license/LICENSE')
mapping('cpp', 'JAVADOC_STYLE')
mapping('h', 'JAVADOC_STYLE')
excludes(['org/apache/weex/utils/WXDataStructureUtil.java'])
}
task weex_core_license(type: com.hierynomus.gradle.license.tasks.LicenseFormat) {
source = fileTree(dir: "../../weex_core").include(['**/*.h', '**/*.cpp', '**/*.cc', '**/*.c']).
exclude(['Source/rapidjson/**/*.h', 'Source/rapidjson/**/*.cpp',
'Source/android/jniprebuild/jniheader/*.h',
'Source/base/Compatible.cpp',
'Source/IPC/**/*.h', 'Source/IPC/**/*.cpp', 'Source/IPC/**/*.c',
'Source/base/base64/modp_base64/**/*.h',
'Source/base/base64/modp_base64/**/*.cc',
'Source/base/third_party/icu/*.h',
'Source/base/third_party/icu/*.cpp',
'Source/android/jsengine/dependence/**/*.h',
'Source/android/jsengine/dependence/**/*.cpp',
'Source/include/wtf/**/*.h',
'Source/include/wtf/**/*.c',
'Source/include/wtf/**/*.cpp',
'Source/include/JavaScriptCore/**/*.h',
'Source/include/JavaScriptCore/**/*.c',
'Source/include/JavaScriptCore/**/*.cpp'])
}
preBuild.dependsOn licenseFormat, copyJSCHeaderToWeexCore
clean.dependsOn cleanCopyJSCHeaderToWeexCore