Skip to content
This repository was archived by the owner on Jun 3, 2021. It is now read-only.

Commit c542823

Browse files
YorkShenlucky-chen
authored andcommitted
[Android] Split build.gradle file into 5 files. (#2927)
1 parent 9b07a12 commit c542823

File tree

7 files changed

+223
-221
lines changed

7 files changed

+223
-221
lines changed

android/build.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ ext {
5858
fastjsonLibVersion="1.1.70.android"
5959
//Default value for disableCov is false
6060
disableCov = project.hasProperty("disableCov") && disableCov.equals("true")
61+
useApachePackageName = project.hasProperty('apachePackageName') ? project.property('apachePackageName').toBoolean() : true
6162
implementFromWeex = true
6263
}
6364

android/sdk/build.gradle

Lines changed: 7 additions & 221 deletions
Original file line numberDiff line numberDiff line change
@@ -26,20 +26,11 @@ apply plugin: 'checkstyle'
2626
apply plugin: 'com.jfrog.bintray'
2727
apply plugin: 'com.github.dcendents.android-maven'
2828

29-
task checkstyle(type: Checkstyle) {
30-
configFile file("${project.rootDir}/sdk/config/quality/checkstyle.xml") // Where my checkstyle config is...
31-
// configProperties.checkstyleSuppressionsPath = file("${project.rootDir}/config/quality/checkstyle/suppressions.xml").absolutePath // Where is my suppressions file for checkstyle is...
32-
source 'src'
33-
include '**/*.java'
34-
exclude '**/gen/**'
35-
exclude '**/test/**'
36-
exclude '**/com/taobao/weex/dom/flex/**'
37-
classpath = files()
38-
}
39-
40-
checkstyle {
41-
toolVersion = '6.9'
42-
}
29+
apply from: 'buildSrc/asan.gradle'
30+
apply from: 'buildSrc/jcenter.gradle'
31+
apply from: 'buildSrc/unstripped.gradle'
32+
apply from: 'buildSrc/checkStyle.gradle'
33+
apply from: 'buildSrc/packageName.gradle'
4334

4435
version = project.hasProperty('weexVersion') ? project.getProperty('weexVersion') : '0.26.0.1'
4536

@@ -62,8 +53,6 @@ if (!project.hasProperty('ignoreVersionCheck') || !project.getProperty('ignoreVe
6253
}
6354
}
6455

65-
def useApachePackageName = project.hasProperty('apachePackageName') ? project.property('apachePackageName').toBoolean() : true
66-
6756
android {
6857
compileSdkVersion project.compileSdkVersion
6958
resourcePrefix "weex"
@@ -114,7 +103,7 @@ android {
114103

115104
def buildRuntimeApi = project.hasProperty('buildRuntimeApi') ? project.property('buildRuntimeApi') : false
116105

117-
defaultPublishConfig useApachePackageName ? 'apacheRelease' : 'legacyRelease'
106+
defaultPublishConfig project.useApachePackageName ? 'apacheRelease' : 'legacyRelease'
118107

119108
defaultConfig {
120109
buildConfigField "String", "buildJavascriptFrameworkVersion", "\"${jsfmVersion}\""
@@ -188,7 +177,7 @@ android {
188177
sourceSets {
189178
main.assets.srcDirs = ['assets']
190179
main.jniLibs.srcDirs = ['libs']
191-
if(!useApachePackageName){
180+
if(!project.useApachePackageName){
192181
main.java.srcDirs = ['src/legacyRelease/java']
193182
main.manifest.srcFile (new File('src/legacyRelease/AndroidManifest.xml'))
194183
}
@@ -267,207 +256,4 @@ task weex_core_license(type: com.hierynomus.gradle.license.tasks.LicenseFormat)
267256
'Source/include/JavaScriptCore/**/*.cpp'])
268257
}
269258

270-
def ndkDir = ''
271-
task checkNdkVersion() {
272-
def rootDir = project.rootDir
273-
def localProperties = new File(rootDir, "local.properties")
274-
if (localProperties.exists()) {
275-
Properties properties = new Properties()
276-
localProperties.withInputStream { instr ->
277-
properties.load(instr)
278-
}
279-
ndkDir = properties.getProperty('ndk.dir')
280-
}
281-
}
282-
283-
def siteUrl = 'https://weex.incubator.apache.org'
284-
def gitUrl = 'https://github.com/apache/incubator-weex.git'
285-
group = "com.taobao.android"
286-
install {
287-
repositories.mavenInstaller {
288-
// This generates POM.xml with proper parameters
289-
pom {
290-
project {
291-
packaging 'aar'
292-
name 'weex_sdk'
293-
url siteUrl
294-
licenses {
295-
license {
296-
name 'The Apache Software License, Version 2.0'
297-
url 'https://www.apache.org/licenses/LICENSE-2.0.txt'
298-
}
299-
}
300-
developers {
301-
developer {
302-
id 'weex alibaba'
303-
name 'weex alibaba'
304-
305-
}
306-
}
307-
scm {
308-
connection gitUrl
309-
developerConnection gitUrl
310-
url siteUrl
311-
}
312-
}
313-
}
314-
}
315-
}
316-
317-
bintray {
318-
configurations = ['archives']
319-
user = project.hasProperty('bintrayUser') ? project.property('bintrayUser') : System.getenv('BINTRAY_USER')
320-
key = project.hasProperty('bintrayApiKey') ? project.property('bintrayApiKey') : System.getenv('BINTRAY_API_KEY')
321-
pkg {
322-
repo = "maven"
323-
name = "weex_sdk"
324-
websiteUrl = siteUrl
325-
vcsUrl = gitUrl
326-
licenses = ["Apache-2.0"]
327-
publish = true
328-
version {
329-
//The version to be published
330-
name = project.version
331-
vcsTag = project.version
332-
}
333-
}
334-
}
335-
artifactory {
336-
contextUrl = 'http://oss.jfrog.org/artifactory'
337-
publish {
338-
repository {
339-
repoKey = 'oss-snapshot-local'
340-
username = bintray.user
341-
password = bintray.key
342-
maven = true
343-
}
344-
defaults {
345-
publishConfigs('archives')
346-
}
347-
}
348-
}
349-
def asanAbi = project.hasProperty('asanAbi') ? project.getProperty('asanAbi') : 'arm64-v8a'
350-
task clearASanLibs(type: Delete){
351-
delete project.android.sourceSets.main.resources.srcDirs
352-
delete fileTree(project.android.sourceSets.main.jniLibs.srcDirs[-1]) {
353-
include '**/libclang_rt.asan-*-android.so'
354-
}
355-
}
356-
task copyWrapScript(type: Copy,dependsOn: clearASanLibs) {
357-
if(project.hasProperty('enableASan') && "true" == project.getProperty('enableASan')) {
358-
from 'wrap.sh'
359-
into new File(project.android.sourceSets.main.resources.srcDirs[-1], "lib")
360-
eachFile {
361-
it.path = "${asanAbi}/${it.name}"
362-
}
363-
}
364-
}
365-
task copyASanLib(type: Copy,dependsOn: copyWrapScript){
366-
if(project.hasProperty('enableASan') && "true" == project.getProperty('enableASan')) {
367-
def ndkPath = ndkDir == '' ? System.getenv("ANDROID_NDK_HOME"):ndkDir
368-
def dir = ndkPath + '/toolchains/llvm/prebuilt/'
369-
def renamedAbi = asanAbi
370-
if (asanAbi == "armeabi-v7a" || asanAbi == "armeabi")
371-
renamedAbi = "arm"
372-
if (asanAbi == "arm64-v8a")
373-
renamedAbi = "aarch64"
374-
if (asanAbi == "x86")
375-
renamedAbi = "i686"
376-
new File(dir).eachFileRecurse { file ->
377-
if (file.name == 'libclang_rt.asan-' + renamedAbi + '-android.so')
378-
from file.absolutePath
379-
into project.android.sourceSets.main.jniLibs.srcDirs[-1]
380-
eachFile {
381-
it.path = "${asanAbi}/${it.name}"
382-
}
383-
includeEmptyDirs = false
384-
}
385-
}
386-
}
387-
388-
task copyAndRenamePackage(type: Copy) {
389-
if(!useApachePackageName) {
390-
doFirst {
391-
delete new File('src/legacyRelease/java')
392-
}
393-
from new File('src/main/java/com/taobao/weex')
394-
into new File('src/legacyRelease/java/org/apache/weex')
395-
filter { String line ->
396-
line.replaceAll(/^(package com\.taobao)(\.weex.*)$/, { _, packageName, suffix ->
397-
"package org.apache${suffix}"
398-
}).replaceAll(/^(import com\.taobao)(\.weex.*)$/, { _, packageName, suffix ->
399-
"import org.apache${suffix}"
400-
}).replaceAll(/^(import static com\.taobao)(\.weex.*)$/, { _, packageName, suffix ->
401-
"import static org.apache${suffix}"
402-
})
403-
}
404-
}
405-
}
406-
407-
task copyManifest(type: Copy){
408-
if(!useApachePackageName){
409-
doFirst {
410-
delete new File('src/legacyRelease/AndroidManifest.xml')
411-
}
412-
from new File('src/main/AndroidManifest.xml')
413-
into new File('src/legacyRelease')
414-
filter { String line ->
415-
line.replaceAll(/(com\.taobao)(\.weex.*)/, { _, packageName, suffix ->
416-
"org.apache${suffix}"
417-
})
418-
}
419-
}
420-
}
421-
422-
def processNativeLibs = { unstripped, stripped ->
423-
copy{
424-
from unstripped
425-
into new File(project.buildDir, "unstrippedSo")
426-
include '**/libweexjss.so', '**/libweexcore.so'
427-
eachFile {
428-
it.path = "${it.relativePath.segments[-2]}_${it.name}"
429-
}
430-
}
431-
432-
if(project.hasProperty('supportArmeabi') && "true" == project.getProperty('supportArmeabi')){
433-
//Copy stripped shared library from armeabi-v7a into armeabi
434-
copy{
435-
from stripped
436-
into project.android.sourceSets.main.jniLibs.srcDirs[-1]
437-
include '**/armeabi-v7a/**'
438-
exclude '**/libc++_shared.so'
439-
eachFile {
440-
it.path = "armeabi/${it.name}"
441-
}
442-
}
443-
444-
//Copy Unstripped shared library from armeabi-v7a into armeabi
445-
copy{
446-
from unstripped
447-
into new File(project.buildDir, "unstrippedSo")
448-
include '**/armeabi-v7a/libweexjss.so', '**/armeabi-v7a/libweexcore.so'
449-
eachFile {
450-
it.path = "armeabi_${it.name}"
451-
}
452-
}
453-
}
454-
}
455-
456-
afterEvaluate { project ->
457-
transformNativeLibsWithStripDebugSymbolForRelease << {
458-
processNativeLibs transformNativeLibsWithMergeJniLibsForRelease,
459-
transformNativeLibsWithStripDebugSymbolForRelease
460-
}
461-
462-
transformNativeLibsWithStripDebugSymbolForApacheRelease << {
463-
processNativeLibs transformNativeLibsWithMergeJniLibsForApacheRelease,
464-
transformNativeLibsWithStripDebugSymbolForApacheRelease
465-
}
466-
467-
transformNativeLibsWithStripDebugSymbolForLegacyRelease << {
468-
processNativeLibs transformNativeLibsWithMergeJniLibsForLegacyRelease,
469-
transformNativeLibsWithStripDebugSymbolForLegacyRelease
470-
}
471-
}
472-
473259
preBuild.dependsOn copyAndRenamePackage, copyManifest, copyASanLib, checkNdkVersion, licenseFormat

android/sdk/buildSrc/asan.gradle

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
def asanAbi = project.hasProperty('asanAbi') ? project.getProperty('asanAbi') : 'arm64-v8a'
2+
def ndkDir = ''
3+
4+
task checkNdkVersion() {
5+
def rootDir = project.rootDir
6+
def localProperties = new File(rootDir, "local.properties")
7+
if (localProperties.exists()) {
8+
Properties properties = new Properties()
9+
localProperties.withInputStream { instr ->
10+
properties.load(instr)
11+
}
12+
ndkDir = properties.getProperty('ndk.dir')
13+
}
14+
}
15+
16+
task clearASanLibs(type: Delete){
17+
delete project.android.sourceSets.main.resources.srcDirs
18+
delete fileTree(project.android.sourceSets.main.jniLibs.srcDirs[-1]) {
19+
include '**/libclang_rt.asan-*-android.so'
20+
}
21+
}
22+
task copyWrapScript(type: Copy,dependsOn: clearASanLibs) {
23+
if(project.hasProperty('enableASan') && "true" == project.getProperty('enableASan')) {
24+
from 'wrap.sh'
25+
into new File(project.android.sourceSets.main.resources.srcDirs[-1], "lib")
26+
eachFile {
27+
it.path = "${asanAbi}/${it.name}"
28+
}
29+
}
30+
}
31+
task copyASanLib(type: Copy,dependsOn: copyWrapScript){
32+
if(project.hasProperty('enableASan') && "true" == project.getProperty('enableASan')) {
33+
def ndkPath = ndkDir == '' ? System.getenv("ANDROID_NDK_HOME"):ndkDir
34+
def dir = ndkPath + '/toolchains/llvm/prebuilt/'
35+
def renamedAbi = asanAbi
36+
if (asanAbi == "armeabi-v7a" || asanAbi == "armeabi")
37+
renamedAbi = "arm"
38+
if (asanAbi == "arm64-v8a")
39+
renamedAbi = "aarch64"
40+
if (asanAbi == "x86")
41+
renamedAbi = "i686"
42+
new File(dir).eachFileRecurse { file ->
43+
if (file.name == 'libclang_rt.asan-' + renamedAbi + '-android.so')
44+
from file.absolutePath
45+
into project.android.sourceSets.main.jniLibs.srcDirs[-1]
46+
eachFile {
47+
it.path = "${asanAbi}/${it.name}"
48+
}
49+
includeEmptyDirs = false
50+
}
51+
}
52+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
task checkstyle(type: Checkstyle) {
2+
configFile file("${project.rootDir}/sdk/config/quality/checkstyle.xml") // Where my checkstyle config is...
3+
// configProperties.checkstyleSuppressionsPath = file("${project.rootDir}/config/quality/checkstyle/suppressions.xml").absolutePath // Where is my suppressions file for checkstyle is...
4+
source 'src'
5+
include '**/*.java'
6+
exclude '**/gen/**'
7+
exclude '**/test/**'
8+
exclude '**/com/taobao/weex/dom/flex/**'
9+
classpath = files()
10+
}
11+
12+
checkstyle {
13+
toolVersion = '6.9'
14+
}

0 commit comments

Comments
 (0)