cordova-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From na...@apache.org
Subject [01/19] git commit: CB-7512 Make key password optional & prompt for it when missing
Date Thu, 09 Oct 2014 20:22:33 GMT
Repository: cordova-amazon-fireos
Updated Branches:
  refs/heads/master e95f47a8d -> 30afdfff4


CB-7512 Make key password optional & prompt for it when missing


Project: http://git-wip-us.apache.org/repos/asf/cordova-amazon-fireos/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-amazon-fireos/commit/68a92cec
Tree: http://git-wip-us.apache.org/repos/asf/cordova-amazon-fireos/tree/68a92cec
Diff: http://git-wip-us.apache.org/repos/asf/cordova-amazon-fireos/diff/68a92cec

Branch: refs/heads/master
Commit: 68a92cec14ae6bd27f5fb39310ee342104f38dfc
Parents: e95f47a
Author: Andrew Grieve <agrieve@chromium.org>
Authored: Wed Sep 17 15:29:57 2014 -0400
Committer: Prabhjot Singh <prabhjos@amazon.com>
Committed: Mon Oct 6 14:39:34 2014 +0530

----------------------------------------------------------------------
 bin/templates/project/build.gradle | 49 +++++++++++++++++++++++++++++++--
 1 file changed, 46 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-amazon-fireos/blob/68a92cec/bin/templates/project/build.gradle
----------------------------------------------------------------------
diff --git a/bin/templates/project/build.gradle b/bin/templates/project/build.gradle
index a1f74b9..96ea009 100644
--- a/bin/templates/project/build.gradle
+++ b/bin/templates/project/build.gradle
@@ -18,6 +18,7 @@
 */
 
 import java.util.regex.Pattern
+import groovy.swing.SwingBuilder
 
 ext.cordova = {}
 apply from: 'cordova.gradle', to: ext.cordova
@@ -115,6 +116,49 @@ task wrapper(type: Wrapper) {
     gradleVersion = '1.12'
 }
 
+def promptForPassword(msg) {
+    if (System.console() == null) {
+        def ret = null
+        new SwingBuilder().edt {
+            dialog(modal: true, title: 'Enter password', alwaysOnTop: true, resizable: false,
locationRelativeTo: null, pack: true, show: true) {
+                vbox {
+                    label(text: msg)
+                    def input = passwordField()
+                    button(defaultButton: true, text: 'OK', actionPerformed: {
+                        ret = input.password;
+                        dispose();
+                    })
+                }
+            }
+        }
+        if (!ret) {
+            throw new GradleException('User canceled build')
+        }
+        return new String(ret)
+    } else {
+        return System.console().readPassword('\n' + msg);
+    }
+}
+
+task promptForReleaseKeyPassword {
+    if (!System.env.RELEASE_SIGNING_PROPERTIES_FILE) {
+        return;
+    }
+    if (!android.signingConfigs.release.storePassword) {
+        android.signingConfigs.release.storePassword = promptForPassword('Enter key store
password: ')
+        println('set to:' + android.signingConfigs.release.storePassword)
+    }
+    if (!android.signingConfigs.release.keyPassword) {
+        android.signingConfigs.release.keyPassword = promptForPassword('Enter key password:
');
+    }
+}
+
+tasks.whenTaskAdded { task ->
+    if (task.name == 'validateReleaseSigning') {
+        task.dependsOn promptForReleaseKeyPassword
+    }
+}
+
 def getVersionCodeFromManifest() {
     def manifestFile = file(android.sourceSets.main.manifest.srcFile)
     def pattern = Pattern.compile("versionCode=\"(\\d+)\"")
@@ -147,10 +191,9 @@ def addSigningProps(propsFilePath, signingConfig) {
         def props = new Properties()
         props.load(reader)
         signingConfig.keyAlias = ensureValueExists(propsFilePath, props, 'keyAlias')
-        signingConfig.keyPassword = ensureValueExists(propsFilePath, props, 'keyPassword')
+        signingConfig.keyPassword = props.get('keyPassword')
         signingConfig.storeFile = RelativePath.parse(true, ensureValueExists(propsFilePath,
props, 'storeFile')).getFile(propsFile.getParentFile())
-        signingConfig.storePassword = ensureValueExists(propsFilePath, props, 'storePassword')
+        signingConfig.storePassword = props.get('storePassword')
     }
 }
 
-


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org


Mime
View raw message