From f6a2b1c88255b1027ae3ff1b72db889d39cb8fd7 Mon Sep 17 00:00:00 2001 From: topjohnwu Date: Thu, 2 Jul 2020 05:01:55 -0700 Subject: [PATCH] Minor gradle script changes --- build.gradle | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/build.gradle b/build.gradle index 83b2e097e..347e2dd73 100644 --- a/build.gradle +++ b/build.gradle @@ -2,12 +2,6 @@ import java.nio.file.Paths // Top-level build file where you can add configuration options common to all sub-projects/modules. -def props = new Properties() -def configPath = project.hasProperty('configPath') ? - new File(project.configPath) : rootProject.file('config.prop') -if (configPath.exists()) - configPath.withInputStream { is -> props.load(is) } - buildscript { ext.vKotlin = '1.3.72' ext.vNav = '2.3.0' @@ -33,6 +27,13 @@ task clean(type: Delete) { delete rootProject.buildDir } +String.metaClass.toFile = { new File(this) } +def configFile = rootProject.findProperty('configPath')?.toFile() ?: rootProject.file('config.prop') +if (!configFile.exists()) + throw new GradleException("Please setup config.prop") + +def props = new Properties() +configFile.withInputStream { is -> props.load(is) } ext.props = props subprojects { @@ -98,17 +99,19 @@ subprojects { android { signingConfigs { config { - storeFile new File(props['keyStore']) - storePassword props['keyStorePass'] - keyAlias props['keyAlias'] - keyPassword props['keyPass'] + if (props.containsKey('keyStore')) { + storeFile new File(props['keyStore']) + storePassword props['keyStorePass'] + keyAlias props['keyAlias'] + keyPassword props['keyPass'] + } } } buildTypes { debug { // If keystore exists, sign the APK with custom signature - if (signingConfigs.config.storeFile.exists()) + if (signingConfigs.config.storeFile?.exists()) signingConfig signingConfigs.config } release {