From 45980ff53d1c5436c00c6fe989a6e13fc7a3c478 Mon Sep 17 00:00:00 2001 From: Mariotaku Lee Date: Sun, 22 Nov 2015 23:38:11 +0800 Subject: [PATCH] updated build script --- build.gradle | 151 +++++++++++++++++++++++---------------------------- 1 file changed, 67 insertions(+), 84 deletions(-) diff --git a/build.gradle b/build.gradle index 69c855dd5..c4f157275 100644 --- a/build.gradle +++ b/build.gradle @@ -1,6 +1,3 @@ -import com.android.build.gradle.AppPlugin -import com.android.build.gradle.LibraryPlugin - apply plugin: 'com.github.ben-manes.versions' // Top-level build file where you can add configuration options common to all sub-projects/modules. @@ -31,101 +28,87 @@ allprojects { } subprojects { + afterEvaluate { project -> + if (project.hasProperty('android')) { + android { + compileSdkVersion 23 + buildToolsVersion '23.0.1' - plugins.withType(LibraryPlugin) { - android { - compileSdkVersion 23 - buildToolsVersion '23.0.1' + lintOptions { + abortOnError false + lintConfig rootProject.file('lint.xml') + } - lintOptions { - abortOnError false - lintConfig rootProject.file('lint.xml') - } - - packagingOptions { - exclude 'META-INF/DEPENDENCIES' - exclude 'META-INF/LICENSE' - exclude 'META-INF/LICENSE.txt' - exclude 'META-INF/license.txt' - exclude 'META-INF/NOTICE' - exclude 'META-INF/NOTICE.txt' - exclude 'META-INF/notice.txt' - exclude 'META-INF/ASL2.0' + packagingOptions { + exclude 'META-INF/DEPENDENCIES' + exclude 'META-INF/LICENSE' + exclude 'META-INF/LICENSE.txt' + exclude 'META-INF/license.txt' + exclude 'META-INF/NOTICE' + exclude 'META-INF/NOTICE.txt' + exclude 'META-INF/notice.txt' + exclude 'META-INF/ASL2.0' + } } } - } - plugins.withType(AppPlugin) { + project.plugins.withId('com.android.application') { - android { - compileSdkVersion 23 - buildToolsVersion '23.0.1' + android { - lintOptions { - abortOnError false - lintConfig rootProject.file('lint.xml') - } - - signingConfigs { - debug { - File signingPropFile = rootProject.file('signing.properties') - if (signingPropFile.exists()) { - Properties signingProp = new Properties() - signingProp.load(signingPropFile.newDataInputStream()) - storeFile file(signingProp.get("debug.storeFile")) - storePassword signingProp.get("debug.storePassword") - keyAlias signingProp.get("debug.keyAlias") - keyPassword signingProp.get("debug.keyPassword") - } else if (System.getenv('DEBUG_KEYSTORE_BASE64') != null) { - storeFile decodeKeyStoreFileFromBase64Env('DEBUG_KEYSTORE_BASE64') - storePassword System.getenv('DEBUG_KEYSTORE_PASSWORD') - keyAlias System.getenv('DEBUG_KEYSTORE_KEY_ALIAS') - keyPassword System.getenv('DEBUG_KEYSTORE_KEY_PASSWORD') + signingConfigs { + debug { + File signingPropFile = rootProject.file('signing.properties') + if (signingPropFile.exists()) { + Properties signingProp = new Properties() + signingProp.load(signingPropFile.newDataInputStream()) + storeFile file(signingProp.get("debug.storeFile")) + storePassword signingProp.get("debug.storePassword") + keyAlias signingProp.get("debug.keyAlias") + keyPassword signingProp.get("debug.keyPassword") + } else if (System.getenv('DEBUG_KEYSTORE_BASE64') != null) { + storeFile decodeKeyStoreFileFromBase64Env('DEBUG_KEYSTORE_BASE64') + storePassword System.getenv('DEBUG_KEYSTORE_PASSWORD') + keyAlias System.getenv('DEBUG_KEYSTORE_KEY_ALIAS') + keyPassword System.getenv('DEBUG_KEYSTORE_KEY_PASSWORD') + } + } + release { + File signingPropFile = rootProject.file('signing.properties') + if (signingPropFile.exists()) { + Properties signingProp = new Properties() + signingProp.load(signingPropFile.newDataInputStream()) + storeFile file(signingProp.get("release.storeFile")) + storePassword signingProp.get("release.storePassword") + keyAlias signingProp.get("release.keyAlias") + keyPassword signingProp.get("release.keyPassword") + } else if (System.getenv('RELEASE_KEYSTORE_BASE64') != null) { + storeFile decodeKeyStoreFileFromBase64Env('RELEASE_KEYSTORE_BASE64') + storePassword System.getenv('RELEASE_KEYSTORE_PASSWORD') + keyAlias System.getenv('RELEASE_KEYSTORE_KEY_ALIAS') + keyPassword System.getenv('RELEASE_KEYSTORE_KEY_PASSWORD') + } } } - release { - File signingPropFile = rootProject.file('signing.properties') - if (signingPropFile.exists()) { - Properties signingProp = new Properties() - signingProp.load(signingPropFile.newDataInputStream()) - storeFile file(signingProp.get("release.storeFile")) - storePassword signingProp.get("release.storePassword") - keyAlias signingProp.get("release.keyAlias") - keyPassword signingProp.get("release.keyPassword") - } else if (System.getenv('RELEASE_KEYSTORE_BASE64') != null) { - storeFile decodeKeyStoreFileFromBase64Env('RELEASE_KEYSTORE_BASE64') - storePassword System.getenv('RELEASE_KEYSTORE_PASSWORD') - keyAlias System.getenv('RELEASE_KEYSTORE_KEY_ALIAS') - keyPassword System.getenv('RELEASE_KEYSTORE_KEY_PASSWORD') + buildTypes { + debug { + if (rootProject.file('signing.properties').exists() + || System.getenv('DEBUG_KEYSTORE_BASE64') != null) { + signingConfig signingConfigs.debug + } + } + release { + if (rootProject.file('signing.properties').exists() + || System.getenv('RELEASE_KEYSTORE_BASE64') != null) { + signingConfig signingConfigs.release + } } } } - buildTypes { - debug { - if (rootProject.file('signing.properties').exists() - || System.getenv('DEBUG_KEYSTORE_BASE64') != null) { - signingConfig signingConfigs.debug - } - } - release { - if (rootProject.file('signing.properties').exists() - || System.getenv('RELEASE_KEYSTORE_BASE64') != null) { - signingConfig signingConfigs.release - } - } - } - packagingOptions { - exclude 'META-INF/DEPENDENCIES' - exclude 'META-INF/LICENSE' - exclude 'META-INF/LICENSE.txt' - exclude 'META-INF/license.txt' - exclude 'META-INF/NOTICE' - exclude 'META-INF/NOTICE.txt' - exclude 'META-INF/notice.txt' - exclude 'META-INF/ASL2.0' - } } + } + } task clean(type: Delete) {