From 77c51d3ae7ddbd79afe30100600fa5e155bcbaa7 Mon Sep 17 00:00:00 2001 From: Andrew Grieve Date: Tue, 21 Oct 2014 12:43:30 -0400 Subject: [PATCH] gradle: Allow absolute paths to keystore files --- bin/templates/project/build.gradle | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/bin/templates/project/build.gradle b/bin/templates/project/build.gradle index 2e4d5cbb..974a19f1 100644 --- a/bin/templates/project/build.gradle +++ b/bin/templates/project/build.gradle @@ -180,14 +180,21 @@ def ensureValueExists(filePath, props, key) { def addSigningProps(propsFilePath, signingConfig) { def propsFile = file(propsFilePath) + def props = new Properties() propsFile.withReader { reader -> - def props = new Properties() props.load(reader) - signingConfig.keyAlias = ensureValueExists(propsFilePath, props, 'keyAlias') - signingConfig.keyPassword = props.get('keyPassword') - signingConfig.storeFile = RelativePath.parse(true, ensureValueExists(propsFilePath, props, 'storeFile')).getFile(propsFile.getParentFile()) - signingConfig.storePassword = props.get('storePassword') } + def storeFile = new File(ensureValueExists(propsFilePath, props, 'storeFile')) + if (!storeFile.isAbsolute()) { + storeFile = RelativePath.parse(true, storeFile.toString()).getFile(propsFile.getParentFile()) + } + if (!storeFile.exists()) { + throw new FileNotFoundException('Keystore file does not exist: ' + storeFile.getAbsolutePath()) + } + signingConfig.keyAlias = ensureValueExists(propsFilePath, props, 'keyAlias') + signingConfig.keyPassword = props.get('keyPassword') + signingConfig.storeFile = storeFile + signingConfig.storePassword = props.get('storePassword') } if (file('build-extras.gradle').exists()) {