You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hc.apache.org by ol...@apache.org on 2013/07/23 15:53:58 UTC

svn commit: r1506045 - in /httpcomponents/project-release-tools/trunk: buildSrc/src/main/groovy/Digest.groovy buildSrc/src/main/groovy/DigestHash.groovy rc.gradle

Author: olegk
Date: Tue Jul 23 13:53:57 2013
New Revision: 1506045

URL: http://svn.apache.org/r1506045
Log:
Improved md5 hash generation; ensure all artifacts including signatures and md5 hashes belong to a common artifact collection (archives)

Added:
    httpcomponents/project-release-tools/trunk/buildSrc/src/main/groovy/DigestHash.groovy
Modified:
    httpcomponents/project-release-tools/trunk/buildSrc/src/main/groovy/Digest.groovy
    httpcomponents/project-release-tools/trunk/rc.gradle

Modified: httpcomponents/project-release-tools/trunk/buildSrc/src/main/groovy/Digest.groovy
URL: http://svn.apache.org/viewvc/httpcomponents/project-release-tools/trunk/buildSrc/src/main/groovy/Digest.groovy?rev=1506045&r1=1506044&r2=1506045&view=diff
==============================================================================
--- httpcomponents/project-release-tools/trunk/buildSrc/src/main/groovy/Digest.groovy (original)
+++ httpcomponents/project-release-tools/trunk/buildSrc/src/main/groovy/Digest.groovy Tue Jul 23 13:53:57 2013
@@ -26,20 +26,22 @@
  */
 
 import org.gradle.api.DefaultTask
+import org.gradle.api.DomainObjectSet
 import org.gradle.api.artifacts.Configuration
 import org.gradle.api.artifacts.PublishArtifact
+import org.gradle.api.internal.DefaultDomainObjectSet
 import org.gradle.api.tasks.InputFiles
 import org.gradle.api.tasks.OutputFiles
 import org.gradle.api.tasks.TaskAction
 
 class Digest extends DefaultTask {
 
-    private Set<PublishArtifact> artifacts = new HashSet()
+    private final DefaultDomainObjectSet<DigestHash> hashes = new DefaultDomainObjectSet<DigestHash>(DigestHash)
 
     void digest(PublishArtifact... artifacts) {
         for (PublishArtifact artifact in artifacts) {
-            this.artifacts.add(artifact)
             dependsOn(artifact)
+            hashes.add(new DigestHash(artifact))
         }
     }
 
@@ -48,28 +50,31 @@ class Digest extends DefaultTask {
             configuration.allArtifacts.all { PublishArtifact artifact ->
                 digest(artifact)
             }
+            configuration.allArtifacts.whenObjectRemoved { DigestHash artifact ->
+                hashes.remove(hashes.find { it.toDigestArtifact == artifact })
+            }
         }
     }
 
+    DomainObjectSet<DigestHash> getHashes() {
+        hashes
+    }
+
     @InputFiles
     List<File> getSourceFiles() {
-        artifacts*.file
+        hashes*.toDigestArtifact.file
     }
 
     @OutputFiles
     List<File> getDigestFiles() {
-        artifacts.collect { PublishArtifact artifact ->
-            File file = artifact.file
-            new File(file.parent, file.name + ".md5")
-        }
+        hashes*.file
     }
 
     @TaskAction
     void generate() {
-        artifacts.each { PublishArtifact artifact ->
-            File file = artifact.file
-            File digest = new File(file.parent, file.name + ".md5")
-            digest.text = MD5.digest(file)
+        hashes.each { DigestHash artifact ->
+            File digest = artifact.file
+            digest.text = MD5.digest(artifact.toDigestArtifact.file)
             digest
         }
     }

Added: httpcomponents/project-release-tools/trunk/buildSrc/src/main/groovy/DigestHash.groovy
URL: http://svn.apache.org/viewvc/httpcomponents/project-release-tools/trunk/buildSrc/src/main/groovy/DigestHash.groovy?rev=1506045&view=auto
==============================================================================
--- httpcomponents/project-release-tools/trunk/buildSrc/src/main/groovy/DigestHash.groovy (added)
+++ httpcomponents/project-release-tools/trunk/buildSrc/src/main/groovy/DigestHash.groovy Tue Jul 23 13:53:57 2013
@@ -0,0 +1,70 @@
+/*
+ * ====================================================================
+ * 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.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation.  For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ *
+ */
+
+import org.gradle.api.artifacts.PublishArtifact
+import org.gradle.api.internal.artifacts.publish.AbstractPublishArtifact
+
+class DigestHash extends AbstractPublishArtifact  {
+
+    final PublishArtifact toDigestArtifact
+
+    DigestHash(PublishArtifact toDigest, Object... tasks) {
+        super(tasks)
+        this.toDigestArtifact = toDigest
+    }
+
+    @Override
+    String getName() {
+        toDigestArtifact.name
+    }
+
+    @Override
+    String getExtension() {
+        'md5'
+    }
+
+    @Override
+    String getType() {
+        'md5'
+    }
+
+    @Override
+    String getClassifier() {
+        toDigestArtifact.classifier
+    }
+
+    @Override
+    File getFile() {
+        new File(toDigestArtifact.file.path + ".${getExtension()}")
+    }
+
+    @Override
+    Date getDate() {
+        toDigestArtifact.date
+    }
+
+}
\ No newline at end of file

Modified: httpcomponents/project-release-tools/trunk/rc.gradle
URL: http://svn.apache.org/viewvc/httpcomponents/project-release-tools/trunk/rc.gradle?rev=1506045&r1=1506044&r2=1506045&view=diff
==============================================================================
--- httpcomponents/project-release-tools/trunk/rc.gradle (original)
+++ httpcomponents/project-release-tools/trunk/rc.gradle Tue Jul 23 13:53:57 2013
@@ -61,6 +61,10 @@ task showStaged(type: SvnStatus) {
     repo = tasks.prepareStage.repo
 }
 
+configurations {
+    dist
+}
+
 task distWinBin(type: Zip) {
     with docs(rc, Line.CRLF), atrifacts(configurations.rc)
     classifier = 'bin'
@@ -106,29 +110,40 @@ tasks.withType(Tar) { Tar tar ->
     tar.compression = Compression.GZIP
 }
 
-configurations {
-    dist
-}
-
-artifacts {
-    dist distWinBin, distUxBin, distWinOSGiBin, distUxOSGiBin, distWinSrc, distUxSrc
-}
-
-task sign(type: Sign) {
+task sign(type: Sign, dependsOn: prepareStage) {
     sign configurations.dist
 }
 
-task digest(type: Digest) {
+task digest(type: Digest, dependsOn: prepareStage) {
     digest configurations.dist
 }
 
-task copyReleaseNotes(type: Copy, dependsOn: prepareStage) {
+String releaseNotes = "RELEASE_NOTES-${rc.pom.major}.${rc.pom.minor}.x.txt"
+
+task docs(type: Copy, dependsOn: prepareStage) {
     from "${rc.localDir}/RELEASE_NOTES.txt"
     into "${prepareStage.localDir}/" +
             "${rc.pom.artifactId}-${rc.pom.version}-${rcQualifier}"
-    rename { "RELEASE_NOTES-${rc.pom.major}.${rc.pom.minor}.x.txt" }
+    rename { releaseNotes }
 }
 
+artifacts {
+    tasks.withType(AbstractArchiveTask) { AbstractArchiveTask archive ->
+        dist archive
+    }
+    sign.signatures.each { PublishArtifact artifact ->
+        archives artifact
+    }
+    digest.hashes.each { PublishArtifact artifact ->
+        archives artifact
+    }
+    archives(new File(docs.destinationDir, releaseNotes)) {
+        classifier = 'doc'
+    }
+}
+
+assemble.dependsOn = [sign, digest, docs]
+
 task stageUpdate(type: SvnUpdate, dependsOn: prepareStage) {
     repo = tasks.prepareStage.repo
 }
@@ -137,9 +152,6 @@ task addChanges(type: SvnScheduleForAddi
     repo = tasks.prepareStage.repo
 }
 
-task stage(dependsOn: ['prepareStage', 'assemble', 'sign', 'digest', 'copyReleaseNotes']) {
-}
-
 //////////////////////////////////////////////////////////////////////////////////////////
 Copy specs
 //////////////////////////////////////////////////////////////////////////////////////////