You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@groovy.apache.org by pa...@apache.org on 2017/01/07 04:08:35 UTC

[3/6] groovy git commit: push signing of artifacts into the main build instead of the groovy-release repo (more tweaks)

push signing of artifacts into the main build instead of the groovy-release repo (more tweaks)


Project: http://git-wip-us.apache.org/repos/asf/groovy/repo
Commit: http://git-wip-us.apache.org/repos/asf/groovy/commit/e79fcdbd
Tree: http://git-wip-us.apache.org/repos/asf/groovy/tree/e79fcdbd
Diff: http://git-wip-us.apache.org/repos/asf/groovy/diff/e79fcdbd

Branch: refs/heads/master
Commit: e79fcdbd5ac6cce3677dd7270f028d5feff985af
Parents: 0b18eda
Author: paulk <pa...@asert.com.au>
Authored: Fri Jan 6 15:11:01 2017 +1000
Committer: paulk <pa...@asert.com.au>
Committed: Sat Jan 7 14:05:52 2017 +1000

----------------------------------------------------------------------
 build.gradle          |  4 +--
 gradle/signing.gradle | 31 ++++++++---------
 gradle/upload.gradle  | 85 +++++++++++++++++++++-------------------------
 3 files changed, 53 insertions(+), 67 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/groovy/blob/e79fcdbd/build.gradle
----------------------------------------------------------------------
diff --git a/build.gradle b/build.gradle
index 79922b2..70f8732 100644
--- a/build.gradle
+++ b/build.gradle
@@ -72,9 +72,6 @@ indyBanner()
 // TODO use antlr plugin
 //apply plugin: 'antlr'
 
-ext.isReleaseVersion = !groovyVersion.toLowerCase().endsWith("snapshot")
-ext.shouldSign = isReleaseVersion
-
 allprojects {
     apply plugin: 'java'
 
@@ -173,6 +170,7 @@ ext {
     xmlunitVersion = '1.6'
     xstreamVersion = '1.4.9'
     spockVersion = '1.0-groovy-2.4'
+    isReleaseVersion = !groovyVersion.toLowerCase().endsWith("snapshot")
 }
 
 dependencies {

http://git-wip-us.apache.org/repos/asf/groovy/blob/e79fcdbd/gradle/signing.gradle
----------------------------------------------------------------------
diff --git a/gradle/signing.gradle b/gradle/signing.gradle
index 2885163..544c533 100644
--- a/gradle/signing.gradle
+++ b/gradle/signing.gradle
@@ -17,22 +17,20 @@
  *  under the License.
  */
 
-import org.gradle.plugins.signing.Sign
-
 allprojects {
     apply plugin: 'signing'
     signing {
         required {
-            isReleaseVersion &&
-                    (gradle.taskGraph.hasTask('artifactoryPublish') || project.hasProperty('forceSign'))
+            rootProject.ext.isReleaseVersion &&
+                    (gradle.taskGraph.hasTask(':artifactoryPublish') || rootProject.hasProperty('forceSign'))
         }
     }
 }
 
 gradle.taskGraph.whenReady { taskGraph ->
-    if (taskGraph.allTasks.any { it instanceof Sign } || project.hasProperty('forceSign')) {
+    if (project.ext.isReleaseVersion &&
+            (taskGraph.hasTask(':artifactoryPublish') || project.hasProperty('forceSign'))) {
         // Use Java 6's console or Swing to read input (not suitable for CI)
-        project.ext.shouldSign = true
         if (!project.hasProperty('signing.keyId') ||
                 !project.hasProperty('signing.secretKeyRingFile') ||
                 !project.hasProperty('signing.password')) {
@@ -63,30 +61,29 @@ def promptUser(String prompt) {
     def response = ''
     if (System.console() == null) {
         new groovy.swing.SwingBuilder().edt {
-            dialog(modal: true, //Otherwise the build will continue running
-                    title: 'Reponse required', //Dialog title
+            dialog(modal: true, // pause build
+                    title: 'Reponse required', // dialog title
                     alwaysOnTop: true,
                     resizable: false,
-                    locationRelativeTo: null, //Place dialog in center of the screen
-                    pack: true, //We need to pack the dialog (so it will take the size of its children)
+                    locationRelativeTo: null, // centered on screen
+                    pack: true,
                     show: true
-            ){
-                vbox { //Put everything below each other
+            ) {
+                vbox {
                     label(text: "$prompt:")
                     input = passwordField()
                     button(defaultButton: true, text: 'OK', actionPerformed: {
-                        response = new String(input.password); //set pass variable to value of input field
-                        dispose(); //close dialog
+                        response = new String(input.password)
+                        dispose()
                     })
                 }
             }
         }
-    }
-    else{
+    } else {
         response = new String(System.console().readPassword("\n$prompt: "))
     }
 
-    if(response.size() <= 0){
+    if (!response) {
         throw new InvalidUserDataException("Null response detected!")
     }
     response

http://git-wip-us.apache.org/repos/asf/groovy/blob/e79fcdbd/gradle/upload.gradle
----------------------------------------------------------------------
diff --git a/gradle/upload.gradle b/gradle/upload.gradle
index 5668454..419b6f8 100644
--- a/gradle/upload.gradle
+++ b/gradle/upload.gradle
@@ -63,9 +63,7 @@ allprojects {
         repositories {
             mavenDeployer {
                 pom pomConfigureClosure
-                if (shouldSign) {
-                    beforeDeployment { MavenDeployment deployment -> signing.signPom(deployment) }
-                }
+                beforeDeployment { MavenDeployment deployment -> signing.signPom(deployment) }
             }
         }
     }
@@ -74,9 +72,7 @@ allprojects {
         repositories {
             mavenInstaller {
                 pom pomConfigureClosure
-                if (shouldSign) {
-                    beforeDeployment { MavenDeployment deployment -> signing.signPom(deployment) }
-                }
+                beforeDeployment { MavenDeployment deployment -> signing.signPom(deployment) }
             }
         }
     }
@@ -110,19 +106,17 @@ allprojects {
 
     install {
         doFirst {
-            if (shouldSign) {
-                signArchiveTask(jar)
-                signArchiveTask(sourceJar)
-                signArchiveTask(javadocJar)
-                signArchiveTask(groovydocJar)
-                def indyJar = rootProject.ext.deriveFile(jar.archivePath, 'indy')
-                if (indyJar.exists()) {
-                    signWithClassifier('indy', indyJar)
-                }
-                def grooidJar = rootProject.ext.deriveFile(jar.archivePath, 'grooid')
-                if (grooidJar.exists()) {
-                    signWithClassifier('grooid', grooidJar)
-                }
+            signArchiveTask(jar)
+            signArchiveTask(sourceJar)
+            signArchiveTask(javadocJar)
+            signArchiveTask(groovydocJar)
+            def indyJar = rootProject.ext.deriveFile(jar.archivePath, 'indy')
+            if (indyJar.exists()) {
+                signWithClassifier('indy', indyJar)
+            }
+            def grooidJar = rootProject.ext.deriveFile(jar.archivePath, 'grooid')
+            if (grooidJar.exists()) {
+                signWithClassifier('grooid', grooidJar)
             }
         }
     }
@@ -167,36 +161,35 @@ allprojects {
 }
 
 install {
+    dependsOn([distDoc, dist, distBin])
     doFirst {
-        if (shouldSign) {
-            signArchiveTask(jarAll)
-            signArchiveTask(sourceAllJar)
-            signArchiveTask(javadocAllJar)
-            signArchiveTask(groovydocAllJar)
-            signArchiveTask(distBin)
+        signArchiveTask(jarAll)
+        signArchiveTask(sourceAllJar)
+        signArchiveTask(javadocAllJar)
+        signArchiveTask(groovydocAllJar)
+        signArchiveTask(distBin)
 
-            // next three are done as a side effect since it was the easiest approach
-            signing.sign(distSrc.archivePath)
-            signing.sign(distDoc.archivePath)
-            signing.sign(dist.archivePath)
+        // next three are done as a side effect since it was the easiest approach
+        signing.sign(distSrc.archivePath)
+        signing.sign(distDoc.archivePath)
+        signing.sign(dist.archivePath)
 
-            tasks.withType(Jar).matching { it.name.startsWith('backport') }.each { t ->
-                signing.sign(t.classifier, t.archivePath)
-                project.artifacts.add('archives', new File(t.destinationDir, t.archiveName + '.asc')) {
-                    name = t.baseName
-                    classifier = t.classifier
-                    type = t.extension + '.asc'
-                }
+        tasks.withType(Jar).matching { it.name.startsWith('backport') }.each { t ->
+            signing.sign(t.classifier, t.archivePath)
+            project.artifacts.add('archives', new File(t.destinationDir, t.archiveName + '.asc')) {
+                name = t.baseName
+                classifier = t.classifier
+                type = t.extension + '.asc'
             }
+        }
 
-            def indyJar = deriveFile(jarAll.archivePath, 'indy')
-            if (indyJar.exists()) {
-                signWithClassifier('indy', indyJar)
-            }
-            def grooidJar = deriveFile(jarAll.archivePath, 'grooid')
-            if (grooidJar.exists()) {
-                signWithClassifier('grooid', grooidJar)
-            }
+        def indyJar = deriveFile(jarAll.archivePath, 'indy')
+        if (indyJar.exists()) {
+            signWithClassifier('indy', indyJar)
+        }
+        def grooidJar = deriveFile(jarAll.archivePath, 'grooid')
+        if (grooidJar.exists()) {
+            signWithClassifier('grooid', grooidJar)
         }
     }
 }
@@ -259,9 +252,7 @@ ext.pomAll = {
         p.dependencies.clear()
     }
 
-    if (shouldSign) {
-        beforeDeployment { MavenDeployment deployment -> signing.signPom(deployment) }
-    }
+    beforeDeployment { MavenDeployment deployment -> signing.signPom(deployment) }
 }
 
 install {