You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@geode.apache.org by up...@apache.org on 2016/04/15 01:08:39 UTC

incubator-geode git commit: GEODE-1226: Prompt for a password to sign and upload to maven

Repository: incubator-geode
Updated Branches:
  refs/heads/develop ce889fecf -> 3fd1eec91


GEODE-1226: Prompt for a password to sign and upload to maven

The signArchives and uploadArchives tasks require passwords to work.
Adding a flag to request a password prompt to fill in a password.

./gradlew uploadArchives -Paskpass

This will pop up a swing dialog box asking for passwords to sign and
upload archives.

This is not on by default because we don't want developers to have to
enter a password for every build. The build target depends on
signArchives but normally will skip it if the password property is not
set.


Project: http://git-wip-us.apache.org/repos/asf/incubator-geode/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-geode/commit/3fd1eec9
Tree: http://git-wip-us.apache.org/repos/asf/incubator-geode/tree/3fd1eec9
Diff: http://git-wip-us.apache.org/repos/asf/incubator-geode/diff/3fd1eec9

Branch: refs/heads/develop
Commit: 3fd1eec9114b2c72bb620578e118bceba8ea89a7
Parents: ce889fe
Author: Dan Smith <up...@apache.org>
Authored: Thu Apr 14 10:48:31 2016 -0700
Committer: Dan Smith <up...@apache.org>
Committed: Thu Apr 14 16:07:41 2016 -0700

----------------------------------------------------------------------
 .../apache/geode/gradle/PasswordDialog.groovy   | 41 ++++++++++++++++++++
 gradle/publish.gradle                           | 35 +++++++++++++++++
 2 files changed, 76 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/3fd1eec9/buildSrc/src/main/groovy/org/apache/geode/gradle/PasswordDialog.groovy
----------------------------------------------------------------------
diff --git a/buildSrc/src/main/groovy/org/apache/geode/gradle/PasswordDialog.groovy b/buildSrc/src/main/groovy/org/apache/geode/gradle/PasswordDialog.groovy
new file mode 100644
index 0000000..bcd2243
--- /dev/null
+++ b/buildSrc/src/main/groovy/org/apache/geode/gradle/PasswordDialog.groovy
@@ -0,0 +1,41 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+import groovy.swing.SwingBuilder
+class PasswordDialog {
+  static String askPassword(String prompt) {
+    def password = ''
+    new SwingBuilder().edt {
+    dialog(modal: true, 
+        title: 'Password',
+        alwaysOnTop: true, 
+        locationRelativeTo: null,
+        pack: true, 
+        show: true
+    ) {
+      vbox { 
+        label(text: prompt)
+        input = passwordField()
+        button(defaultButton: true, text: 'OK', actionPerformed: {
+          password = input.password.toString(); // Set pass variable to value of input field
+          dispose(); // Close dialog
+        })
+      }
+      }
+    }
+    return password
+  }
+}

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/3fd1eec9/gradle/publish.gradle
----------------------------------------------------------------------
diff --git a/gradle/publish.gradle b/gradle/publish.gradle
index 02b0e3c..9c251c7 100644
--- a/gradle/publish.gradle
+++ b/gradle/publish.gradle
@@ -28,6 +28,7 @@ subprojects {
     repositoryUrl = 'https://repository.apache.org/service/local/staging/deploy/maven2'
     snapshotRepositoryUrl = 'https://repository.apache.org/content/repositories/snapshots'
   }
+
   
   modifyPom {
     withXml {
@@ -119,3 +120,37 @@ subprojects {
     }
   }
 }
+
+//Prompt the user for a password to sign archives or upload artifacts, if requested
+gradle.taskGraph.whenReady { taskGraph ->
+  if (project.hasProperty('askpass')) {
+    if(taskGraph.allTasks.any {it instanceof Sign}) {
+      if(!project.hasProperty('signing.keyId') || !project.hasProperty('signing.secretKeyRingFile')) {
+        println "You must configure your signing.keyId and signing.secretKeyRingFile"
+        println "in ~/gradle/.properties in order to sign jars\n"
+        println "See https://cwiki.apache.org/confluence/display/GEODE/Release+Steps"
+        throw new GradleException("Signing key/keyring is missing")
+      }
+
+      if(!project.hasProperty('signing.password')) {
+        def password = PasswordDialog.askPassword("Please enter your password to unlock your gpg keyring for signing artifacts")
+        
+        subprojects { ext."signing.password" = password }
+      }
+    }
+
+    if(taskGraph.allTasks.any {it.name == 'uploadArchives'}) {
+      if(!project.hasProperty('nexusUsername')) {
+        println "You must configure your nexusUsername in ~/gradle/.properties in order to uploadArchives\n"
+        println "See https://cwiki.apache.org/confluence/display/GEODE/Release+Steps"
+        throw new GradleException("nexusUsername is missing")
+      }
+
+      if(!project.hasProperty('nexusPassword')) {
+        def password = PasswordDialog.askPassword("Please enter your apache password to uploadArchives to nexus")
+        
+        subprojects { ext."nexusPassword" = password }
+      }
+    }
+  }
+}