From b5c50919e3a2e7e150eedcb4cf89c419721f6a91 Mon Sep 17 00:00:00 2001 From: str4d Date: Sat, 28 Jun 2014 03:58:22 +0000 Subject: [PATCH] Improved handling of signing keys --- .mtn-ignore | 2 +- app/build.gradle | 28 +++++++++++++++++++++++++++- 2 files changed, 28 insertions(+), 2 deletions(-) diff --git a/.mtn-ignore b/.mtn-ignore index 8dfcbe1..2bbcf81 100644 --- a/.mtn-ignore +++ b/.mtn-ignore @@ -5,7 +5,7 @@ ^botejars/libs lint.xml local.properties -signing.gradle +signing.properties #IntelliJ IDEA ^.idea diff --git a/app/build.gradle b/app/build.gradle index 56fd270..c3c8b8c 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -1,5 +1,4 @@ apply plugin: 'android' -apply from: 'signing.gradle' android { compileSdkVersion 19 @@ -8,6 +7,9 @@ android { minSdkVersion 9 targetSdkVersion 19 } + signingConfigs { + release + } buildTypes { release { signingConfig signingConfigs.release @@ -31,3 +33,27 @@ dependencies { exclude group: 'com.android.support', module: 'support-v4' } } + +def Properties props = new Properties() +def propFile = new File(project.rootDir, 'signing.properties') + +if (propFile.canRead()) { + props.load(new FileInputStream(propFile)) + + if (props != null && + props.containsKey('STORE_FILE') && + props.containsKey('STORE_PASSWORD') && + props.containsKey('KEY_ALIAS') && + props.containsKey('KEY_PASSWORD')) { + android.signingConfigs.release.storeFile = file(props['STORE_FILE']) + android.signingConfigs.release.storePassword = props['STORE_PASSWORD'] + android.signingConfigs.release.keyAlias = props['KEY_ALIAS'] + android.signingConfigs.release.keyPassword = props['KEY_PASSWORD'] + } else { + println 'signing.properties found but some entries are missing' + android.buildTypes.release.signingConfig = null + } +} else { + println 'signing.properties not found' + android.buildTypes.release.signingConfig = null +}