push signing of artifacts into the main build instead of the groovy-release repo


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

Branch: refs/heads/parrot
Commit: bd4e2c7121a26ed9c1b2d16fdaed81e477e7a5f8
Parents: d32a39b
Author: paulk <pa...@asert.com.au>
Authored: Fri Jan 6 00:00:44 2017 +1000
Committer: paulk <pa...@asert.com.au>
Committed: Sat Jan 7 14:03:52 2017 +1000

----------------------------------------------------------------------
 build.gradle                              |  20 +++--
 gradle/assemble.gradle                    |  10 +--
 gradle/backports.gradle                   |   1 +
 gradle/signing.gradle                     |  92 +++++++++++++++++++++
 gradle/upload.gradle                      | 108 ++++++++++++++++++++++---
 subprojects/groovy-templates/build.gradle |   2 +-
 6 files changed, 207 insertions(+), 26 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/groovy/blob/bd4e2c71/build.gradle
----------------------------------------------------------------------
diff --git a/build.gradle b/build.gradle
index a23496b..455edc2 100644
--- a/build.gradle
+++ b/build.gradle
@@ -72,6 +72,8 @@ indyBanner()
 // TODO use antlr plugin
 //apply plugin: 'antlr'
 
+ext.isReleaseVersion = !groovyVersion.toLowerCase().endsWith("snapshot")
+
 allprojects {
     apply plugin: 'java'
 
@@ -472,6 +474,15 @@ task checkCompatibility {
     }
 }
 
+if (!JavaVersion.current().java7Compatible) {
+    logger.lifecycle '''
+    **************************************** WARNING 
********************************************
+    ******   You are running the build with an older JDK. NEVER try to release 
with 1.6.   ******
+    ******   You must use a JDK 1.7+ in order to compile all features of the 
language.     ******
+    
*********************************************************************************************
+'''
+}
+
 apply from: 'gradle/test.gradle'
 apply from: 'gradle/groovydoc.gradle'
 apply from: 'gradle/docs.gradle'
@@ -487,14 +498,7 @@ if (file('user.gradle').exists()) {
     apply from: 'user.gradle'
 }
 
-if (!JavaVersion.current().java7Compatible) {
-    logger.lifecycle '''
-    **************************************** WARNING 
**********************************************
-    ****** You are running the build with an older JDK. NEVER try to release 
with 1.6.       ******
-    ****** You must use a JDK 1.7+ in order to compile all features of the 
language.         ******
-    
***********************************************************************************************
-'''
-}
+apply from: 'gradle/signing.gradle'
 
 licenseReport {
     excludeGroups = [

http://git-wip-us.apache.org/repos/asf/groovy/blob/bd4e2c71/gradle/assemble.gradle
----------------------------------------------------------------------
diff --git a/gradle/assemble.gradle b/gradle/assemble.gradle
index 8922eea..12f2917 100644
--- a/gradle/assemble.gradle
+++ b/gradle/assemble.gradle
@@ -340,7 +340,7 @@ task jarAll(type: Jar, dependsOn: replaceJarWithJarJar) {
     inputs.files(allprojects.jar.archivePath)
 
     ext.metaInfDir = "$buildDir/tmp/groovy-all-metainf"
-    appendix = 'all'
+    baseName = 'groovy-all'
     includeEmptyDirs = false
     if (rootProject.useIndy()) {
         classifier = 'indy'
@@ -447,7 +447,7 @@ task sourceAllJar(type: Jar, dependsOn: { 
modules()*.sourceJar + rootProject.sou
     modules()*.sourceJar.each {
         with it.rootSpec
     }
-    appendix = 'all'
+    baseName = 'groovy-all'
     classifier = rootProject.useIndy() ? 'indy-sources' : 'sources'
 }
 
@@ -463,13 +463,13 @@ allprojects {
 }
 
 task javadocAllJar(type: Jar, dependsOn: javadocAll) {
-    appendix = 'all'
+    baseName = 'groovy-all'
     classifier = rootProject.useIndy() ? 'indy-javadoc' : 'javadoc'
     from javadocAll.destinationDir
 }
 
 task groovydocAllJar(type: Jar, dependsOn: groovydocAll) {
-    appendix = 'all'
+    baseName = 'groovy-all'
     classifier = rootProject.useIndy() ? 'indy-groovydoc' : 'groovydoc'
     from groovydocAll.destinationDir
 }
@@ -531,7 +531,7 @@ ext.distSpec = copySpec {
     }
     into('embeddable') {
         from jarAll.archivePath
-        from { new File(jarAll.archivePath.parent, 
"${jarAll.baseName}-${jarAll.appendix}-${jarAll.version}-indy.jar") }
+        from { new File(jarAll.destinationDir, 
"${jarAll.baseName}-${jarAll.version}-indy.jar") }
     }
 }
 

http://git-wip-us.apache.org/repos/asf/groovy/blob/bd4e2c71/gradle/backports.gradle
----------------------------------------------------------------------
diff --git a/gradle/backports.gradle b/gradle/backports.gradle
index d111c26..0d8e5ed 100644
--- a/gradle/backports.gradle
+++ b/gradle/backports.gradle
@@ -43,6 +43,7 @@ backports.each { pkg, classList ->
         from zipTree(jar.archivePath)
         include classList
         baseName = "groovy-backports-$pkg"
+        classifier = ''
     }
 
     // the following two jars are empty. No wonder, Maven Central *requires* a 
javadoc and sources classifier

http://git-wip-us.apache.org/repos/asf/groovy/blob/bd4e2c71/gradle/signing.gradle
----------------------------------------------------------------------
diff --git a/gradle/signing.gradle b/gradle/signing.gradle
new file mode 100644
index 0000000..89c3a01
--- /dev/null
+++ b/gradle/signing.gradle
@@ -0,0 +1,92 @@
+/*
+ *  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 org.gradle.plugins.signing.Sign
+
+allprojects {
+    apply plugin: 'signing'
+    signing {
+        required {
+            isReleaseVersion &&
+                    (gradle.taskGraph.hasTask('artifactoryPublish') || 
project.hasProperty('forceSign'))
+        }
+    }
+}
+
+gradle.taskGraph.whenReady { taskGraph ->
+    if (taskGraph.allTasks.any { it instanceof Sign } || 
project.hasProperty('forceSign')) {
+        // Use Java 6's console or Swing to read input (not suitable for CI)
+        if (!project.hasProperty('signing.keyId') ||
+                !project.hasProperty('signing.secretKeyRingFile') ||
+                !project.hasProperty('signing.password')) {
+            printf "\n\nWe have to sign some things in this build." +
+                    "\n\nPlease enter your signing details.\n\n"
+            System.out.flush()
+
+            if (!project.hasProperty('signing.keyId')) {
+                project.ext.'signing.keyId' = promptUser('PGP Key Id')
+            }
+            if (!project.hasProperty('signing.secretKeyRingFile')) {
+                project.ext.'signing.secretKeyRingFile' = promptUser('PGP 
Secret Key Ring File (absolute path)')
+            }
+            if (!project.hasProperty('signing.password')) {
+                project.ext.'signing.password' = promptUser('PGP Private Key 
Password')
+            }
+
+            printf "\nThanks.\n\n"
+            System.out.flush()
+        }
+        allprojects { ext.'signing.keyId' = 
project.getProperty('signing.keyId') }
+        allprojects { ext.'signing.secretKeyRingFile' = 
project.getProperty('signing.secretKeyRingFile') }
+        allprojects { ext.'signing.password' = 
project.getProperty('signing.password') }
+    }
+}
+
+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
+                    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)
+                    show: true
+            ){
+                vbox { //Put everything below each other
+                    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
+                    })
+                }
+            }
+        }
+    }
+    else{
+        response = new String(System.console().readPassword("\n$prompt: "))
+    }
+
+    if(response.size() <= 0){
+        throw new InvalidUserDataException("Null response detected!")
+    }
+    response
+}

http://git-wip-us.apache.org/repos/asf/groovy/blob/bd4e2c71/gradle/upload.gradle
----------------------------------------------------------------------
diff --git a/gradle/upload.gradle b/gradle/upload.gradle
index 7659a1d..633df89 100644
--- a/gradle/upload.gradle
+++ b/gradle/upload.gradle
@@ -40,7 +40,25 @@ allprojects {
 
 apply from: 'gradle/backports.gradle'
 
+ext.basename = { String s -> s.take(s.lastIndexOf('.')) }
+ext.deriveFile = { File archive, String suffix -> new File(archive.parent, 
basename(archive.name) + "-${suffix}.jar") }
+
 allprojects {
+    ext.signWithClassifier = { String c, File f ->
+        signing.sign(c, f)
+        project.artifacts.add('archives', new File(f.parent, f.name + '.asc')) 
{
+            classifier = c
+            type = 'jar.asc'
+        }
+    }
+
+    ext.signArchiveTask = { archiveTask ->
+        signing.sign(archiveTask.classifier, archiveTask.archivePath)
+        project.artifacts.add('archives', new File(archiveTask.destinationDir, 
archiveTask.archiveName + '.asc')) {
+            classifier = archiveTask.classifier
+            type = archiveTask.extension + '.asc'
+        }
+    }
 
     configurations {
         deployerJars
@@ -51,6 +69,7 @@ allprojects {
             mavenDeployer {
                 configuration = configurations.deployerJars
                 pom pomConfigureClosure
+                beforeDeployment { MavenDeployment deployment -> 
signing.signPom(deployment) }
             }
         }
     }
@@ -59,6 +78,7 @@ allprojects {
         repositories {
             mavenInstaller {
                 pom pomConfigureClosure
+                beforeDeployment { MavenDeployment deployment -> 
signing.signPom(deployment) }
             }
         }
     }
@@ -79,49 +99,111 @@ allprojects {
                 new GradleException('You cannot use uploadArchives or install 
task with the flag [indy] turned'
                         +' on because the build handles indy artifacts by 
itself in that case.')
             }
-            def archive = jar.archivePath
-            def indyJar = new File(archive.parent, 
archive.name[0..archive.name.lastIndexOf('.')-1]+'-indy.jar')
+            def indyJar = rootProject.ext.deriveFile(jar.archivePath, 'indy')
             if (indyJar.exists()) {
                 project.artifacts.add('archives', indyJar)
             }
-            def grooidJar = new File(archive.parent, 
archive.name[0..archive.name.lastIndexOf('.')-1]+'-grooid.jar')
+            def grooidJar = rootProject.ext.deriveFile(jar.archivePath, 
'grooid')
             if (grooidJar.exists()) {
                 project.artifacts.add('archives', grooidJar)
             }
         }
     }
+
+    install {
+        doFirst {
+            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)
+            }
+        }
+    }
 }
 
 // the root project generates an alternate 'groovy-all' artifact
 [uploadArchives, install]*.with {
     dependsOn([sourceAllJar, javadocAllJar, groovydocAllJar, distBin])
     doFirst {
-        project.artifacts.add('archives', jarAll)
-        project.artifacts.add('archives', sourceAllJar)
-        project.artifacts.add('archives', javadocAllJar)
-        project.artifacts.add('archives', groovydocAllJar)
-        project.artifacts.add('archives', distBin)
+        project.artifacts.add('archives', jarAll) {
+            name = 'groovy-all'
+        }
+        project.artifacts.add('archives', sourceAllJar) {
+            name = 'groovy-all'
+        }
+        project.artifacts.add('archives', javadocAllJar) {
+            name = 'groovy-all'
+        }
+        project.artifacts.add('archives', groovydocAllJar) {
+            name = 'groovy-all'
+        }
+        project.artifacts.add('archives', distBin) {
+            name = 'groovy-binary'
+        }
         tasks.withType(Jar).matching { it.name.startsWith('backport') }.each { 
t ->
             project.artifacts.add('archives', t.archivePath) {
                 name = t.baseName
                 type = 'jar'
+                classifier = t.classifier
             }
         }
 
-        def archive = jarAll.archivePath
-        def indyJar = new File(archive.parent, 
archive.name[0..archive.name.lastIndexOf('.')-1] + '-indy.jar')
+        def indyJar = deriveFile(jarAll.archivePath, 'indy')
         if (indyJar.exists()) {
             project.artifacts.add('archives', indyJar)
         }
-        def grooidJar = new File(archive.parent, 
archive.name[0..archive.name.lastIndexOf('.')-1]+'-grooid.jar')
+        def grooidJar = deriveFile(jarAll.archivePath, 'grooid')
         if (grooidJar.exists()) {
             project.artifacts.add('archives', grooidJar)
         }
     }
 }
+
+install {
+    doFirst {
+        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)
+
+        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)
+        }
+    }
+}
+
 ext.pomAll = {
     addFilter('groovy') { artifact, file ->
-        !(artifact.name.contains('groovy-all')) && 
!(artifact.name.contains('groovy-binary')) && 
!(artifact.name.contains('backport'))
+        !(artifact.name.contains('groovy-all')) &&
+                !(artifact.name.contains('groovy-binary')) &&
+                !(artifact.name.contains('backport'))
     }
     addFilter('all') { artifact, file ->
         artifact.name.contains('groovy-all')
@@ -174,6 +256,8 @@ ext.pomAll = {
     binarypom.whenConfigured { p ->
         p.dependencies.clear()
     }
+
+    beforeDeployment { MavenDeployment deployment -> 
signing.signPom(deployment) }
 }
 
 install {

http://git-wip-us.apache.org/repos/asf/groovy/blob/bd4e2c71/subprojects/groovy-templates/build.gradle
----------------------------------------------------------------------
diff --git a/subprojects/groovy-templates/build.gradle 
b/subprojects/groovy-templates/build.gradle
index 4805b1c..906f37c 100644
--- a/subprojects/groovy-templates/build.gradle
+++ b/subprojects/groovy-templates/build.gradle
@@ -27,7 +27,7 @@ dependencies {
 }
 
 task backportJar(type:Jar) {
-    appendix = 'markup-backport'
+    name = 'groovy-markup-backport'
     dependsOn classes
     from sourceSets.main.output
     include 'groovy/text/markup/**'

Reply via email to