Minor gradle script changes

This commit is contained in:
topjohnwu 2020-07-02 05:01:55 -07:00
parent c2e6622016
commit f6a2b1c882

View File

@ -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. // 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 { buildscript {
ext.vKotlin = '1.3.72' ext.vKotlin = '1.3.72'
ext.vNav = '2.3.0' ext.vNav = '2.3.0'
@ -33,6 +27,13 @@ task clean(type: Delete) {
delete rootProject.buildDir 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 ext.props = props
subprojects { subprojects {
@ -98,17 +99,19 @@ subprojects {
android { android {
signingConfigs { signingConfigs {
config { config {
storeFile new File(props['keyStore']) if (props.containsKey('keyStore')) {
storePassword props['keyStorePass'] storeFile new File(props['keyStore'])
keyAlias props['keyAlias'] storePassword props['keyStorePass']
keyPassword props['keyPass'] keyAlias props['keyAlias']
keyPassword props['keyPass']
}
} }
} }
buildTypes { buildTypes {
debug { debug {
// If keystore exists, sign the APK with custom signature // If keystore exists, sign the APK with custom signature
if (signingConfigs.config.storeFile.exists()) if (signingConfigs.config.storeFile?.exists())
signingConfig signingConfigs.config signingConfig signingConfigs.config
} }
release { release {