You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by gg...@apache.org on 2018/11/13 19:24:57 UTC

commons-release-plugin git commit: Drop SHA-256 code, leaving only SHA-512.

Repository: commons-release-plugin
Updated Branches:
  refs/heads/master 87c24e189 -> 7651f5bc3


Drop SHA-256 code, leaving only SHA-512.

Project: http://git-wip-us.apache.org/repos/asf/commons-release-plugin/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-release-plugin/commit/7651f5bc
Tree: http://git-wip-us.apache.org/repos/asf/commons-release-plugin/tree/7651f5bc
Diff: http://git-wip-us.apache.org/repos/asf/commons-release-plugin/diff/7651f5bc

Branch: refs/heads/master
Commit: 7651f5bc32de10f8e5d9014ca8d39c16d9c417dc
Parents: 87c24e1
Author: Gary Gregory <ga...@gmail.com>
Authored: Tue Nov 13 12:24:54 2018 -0700
Committer: Gary Gregory <ga...@gmail.com>
Committed: Tue Nov 13 12:24:54 2018 -0700

----------------------------------------------------------------------
 src/changes/changes.xml                         |  1 +
 .../CommonsDistributionDetachmentMojo.java      | 72 --------------------
 .../CommonsDistributionDetachmentMojoTest.java  | 10 ---
 .../CommonsDistributionStagingMojoTest.java     |  8 ---
 4 files changed, 1 insertion(+), 90 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/commons-release-plugin/blob/7651f5bc/src/changes/changes.xml
----------------------------------------------------------------------
diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index f27a997..9f79d91 100755
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -30,6 +30,7 @@
       <action type="fix" dev="ggregory">Check the result of checking out files from the SCM.</action>
       <action issue="COMMONSSITE-120" type="update" dev="ggregory">[release-plugin] Use SHA-256 and SHA-512, not MD5, not SHA-1.</action>
       <action type="update" dev="ggregory">Update Apache Commons Compress from 1.17 to 1.18.</action>
+      <action type="update" dev="ggregory">Drop SHA-256 code, leaving only SHA-512.</action>
     </release>
 
     <release version="1.3" date="2018-06-15" description="Version 1.3">

http://git-wip-us.apache.org/repos/asf/commons-release-plugin/blob/7651f5bc/src/main/java/org/apache/commons/release/plugin/mojos/CommonsDistributionDetachmentMojo.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/release/plugin/mojos/CommonsDistributionDetachmentMojo.java b/src/main/java/org/apache/commons/release/plugin/mojos/CommonsDistributionDetachmentMojo.java
index 8528084..4e8d5f2 100755
--- a/src/main/java/org/apache/commons/release/plugin/mojos/CommonsDistributionDetachmentMojo.java
+++ b/src/main/java/org/apache/commons/release/plugin/mojos/CommonsDistributionDetachmentMojo.java
@@ -79,13 +79,6 @@ public class CommonsDistributionDetachmentMojo extends AbstractMojo {
     /**
      * A {@link Properties} of {@link Artifact} → {@link String} containing the sha256 signatures
      * for the individual artifacts, where the {@link Artifact} is represented as:
-     * <code>groupId:artifactId:version:type=sha256</code>.
-     */
-    private final Properties artifactSha256s = new Properties();
-
-    /**
-     * A {@link Properties} of {@link Artifact} → {@link String} containing the sha256 signatures
-     * for the individual artifacts, where the {@link Artifact} is represented as:
      * <code>groupId:artifactId:version:type=sha512</code>.
      */
     private final Properties artifactSha512s = new Properties();
@@ -128,7 +121,6 @@ public class CommonsDistributionDetachmentMojo extends AbstractMojo {
         }
         getLog().info("Detaching Assemblies");
         for (Object attachedArtifact : project.getAttachedArtifacts()) {
-            putAttachedArtifactInSha256Map((Artifact) attachedArtifact);
             putAttachedArtifactInSha512Map((Artifact) attachedArtifact);
             if (ARTIFACT_TYPES_TO_DETACH.contains(((Artifact) attachedArtifact).getType())) {
                 detachedArtifacts.add((Artifact) attachedArtifact);
@@ -144,7 +136,6 @@ public class CommonsDistributionDetachmentMojo extends AbstractMojo {
         if (!workingDirectory.exists()) {
             SharedFunctions.initDirectory(getLog(), workingDirectory);
         }
-        writeAllArtifactsInSha256PropertiesFile();
         writeAllArtifactsInSha512PropertiesFile();
         copyRemovedArtifactsToWorkingDirectory();
         getLog().info("");
@@ -154,32 +145,6 @@ public class CommonsDistributionDetachmentMojo extends AbstractMojo {
     /**
      * Takes an attached artifact and puts the signature in the map.
      * @param artifact is a Maven {@link Artifact} taken from the project at start time of mojo.
-     * @throws MojoExecutionException if an {@link IOException} occurs when getting the sha256 of the
-     *                                artifact.
-     */
-    private void putAttachedArtifactInSha256Map(Artifact artifact) throws MojoExecutionException {
-        try {
-            String artifactKey = getArtifactKey(artifact);
-            try (FileInputStream fis = new FileInputStream(artifact.getFile())) {
-                artifactSha256s.put(artifactKey, DigestUtils.sha256Hex(fis));
-            }
-        } catch (IOException e) {
-            throw new MojoExecutionException(
-                "Could not find artifact signature for: "
-                    + artifact.getArtifactId()
-                    + "-"
-                    + artifact.getClassifier()
-                    + "-"
-                    + artifact.getVersion()
-                    + " type: "
-                    + artifact.getType(),
-                e);
-        }
-    }
-
-    /**
-     * Takes an attached artifact and puts the signature in the map.
-     * @param artifact is a Maven {@link Artifact} taken from the project at start time of mojo.
      * @throws MojoExecutionException if an {@link IOException} occurs when getting the sha512 of the
      *                                artifact.
      */
@@ -204,21 +169,6 @@ public class CommonsDistributionDetachmentMojo extends AbstractMojo {
     }
 
     /**
-     * Writes to ./target/commons-release-plugin/sha256.properties the artifact sha256's.
-     *
-     * @throws MojoExecutionException if we can't write the file due to an {@link IOException}.
-     */
-    private void writeAllArtifactsInSha256PropertiesFile() throws MojoExecutionException {
-        File propertiesFile = new File(workingDirectory, "sha256.properties");
-        getLog().info("Writting " + propertiesFile);
-        try (FileOutputStream fileWriter = new FileOutputStream(propertiesFile)) {
-            artifactSha256s.store(fileWriter, "Release SHA-256s");
-        } catch (IOException e) {
-            throw new MojoExecutionException("Failure to write SHA-256's", e);
-        }
-    }
-
-    /**
      * Writes to ./target/commons-release-plugin/sha512.properties the artifact sha512's.
      *
      * @throws MojoExecutionException if we can't write the file due to an {@link IOException}.
@@ -269,13 +219,6 @@ public class CommonsDistributionDetachmentMojo extends AbstractMojo {
                 String artifactKey = getArtifactKey(artifact);
                 try {
                     String digest;
-                    // SHA-256
-                    digest = artifactSha256s.getProperty(artifactKey.toString());
-                    getLog().info(artifact.getFile().getName() + " sha256: " + digest);
-                    try (PrintWriter printWriter = new PrintWriter(
-                            getSha256FilePath(workingDirectory, artifact.getFile()))) {
-                        printWriter.println(digest);
-                    }
                     // SHA-512
                     digest = artifactSha512s.getProperty(artifactKey.toString());
                     getLog().info(artifact.getFile().getName() + " sha512: " + digest);
@@ -291,21 +234,6 @@ public class CommonsDistributionDetachmentMojo extends AbstractMojo {
     }
 
     /**
-     * A helper method to create a file path for the <code>sha256</code> signature file from a given file.
-     *
-     * @param directory is the {@link File} for the directory in which to make the <code>.sha256</code> file.
-     * @param file the {@link File} whose name we should use to create the <code>.sha256</code> file.
-     * @return a {@link String} that is the absolute path to the <code>.sha256</code> file.
-     */
-    private String getSha256FilePath(File directory, File file) {
-        StringBuilder buffer = new StringBuilder(directory.getAbsolutePath());
-        buffer.append("/");
-        buffer.append(file.getName());
-        buffer.append(".sha256");
-        return buffer.toString();
-    }
-
-    /**
      * A helper method to create a file path for the <code>sha512</code> signature file from a given file.
      *
      * @param directory is the {@link File} for the directory in which to make the <code>.sha512</code> file.

http://git-wip-us.apache.org/repos/asf/commons-release-plugin/blob/7651f5bc/src/test/java/org/apache/commons/release/plugin/mojos/CommonsDistributionDetachmentMojoTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/release/plugin/mojos/CommonsDistributionDetachmentMojoTest.java b/src/test/java/org/apache/commons/release/plugin/mojos/CommonsDistributionDetachmentMojoTest.java
index dd228ea..c49caa7 100755
--- a/src/test/java/org/apache/commons/release/plugin/mojos/CommonsDistributionDetachmentMojoTest.java
+++ b/src/test/java/org/apache/commons/release/plugin/mojos/CommonsDistributionDetachmentMojoTest.java
@@ -67,40 +67,30 @@ public class CommonsDistributionDetachmentMojoTest {
         mojo.execute();
         File detachedSrcTarGz = new File(COMMONS_RELEASE_PLUGIN_TEST_DIR_PATH + "/commons-text-1.4-src.tar.gz");
         File detachedSrcTarGzAsc = new File(COMMONS_RELEASE_PLUGIN_TEST_DIR_PATH + "/commons-text-1.4-src.tar.gz.asc");
-        File detachedSrcTarGzSha256 = new File(COMMONS_RELEASE_PLUGIN_TEST_DIR_PATH + "/commons-text-1.4-src.tar.gz.sha256");
         File detachedSrcTarGzSha512 = new File(COMMONS_RELEASE_PLUGIN_TEST_DIR_PATH + "/commons-text-1.4-src.tar.gz.sha512");
         File detachedSrcZip = new File(COMMONS_RELEASE_PLUGIN_TEST_DIR_PATH + "/commons-text-1.4-src.zip");
         File detachedSrcZipAsc = new File(COMMONS_RELEASE_PLUGIN_TEST_DIR_PATH + "/commons-text-1.4-src.zip.asc");
-        File detachedSrcZipSha256 = new File(COMMONS_RELEASE_PLUGIN_TEST_DIR_PATH + "/commons-text-1.4-src.zip.sha256");
         File detachedSrcZipSha512 = new File(COMMONS_RELEASE_PLUGIN_TEST_DIR_PATH + "/commons-text-1.4-src.zip.sha512");
         File detachedBinTarGz = new File(COMMONS_RELEASE_PLUGIN_TEST_DIR_PATH + "/commons-text-1.4-bin.tar.gz");
         File detachedBinTarGzAsc = new File(COMMONS_RELEASE_PLUGIN_TEST_DIR_PATH + "/commons-text-1.4-bin.tar.gz.asc");
-        File detachedBinTarGzSha256 = new File(COMMONS_RELEASE_PLUGIN_TEST_DIR_PATH + "/commons-text-1.4-bin.tar.gz.sha256");
         File detachedBinTarGzSha512 = new File(COMMONS_RELEASE_PLUGIN_TEST_DIR_PATH + "/commons-text-1.4-bin.tar.gz.sha512");
         File detachedBinZip = new File(COMMONS_RELEASE_PLUGIN_TEST_DIR_PATH + "/commons-text-1.4-bin.zip");
         File detachedBinZipAsc = new File(COMMONS_RELEASE_PLUGIN_TEST_DIR_PATH + "/commons-text-1.4-bin.zip.asc");
-        File detachedBinZipSha256 = new File(COMMONS_RELEASE_PLUGIN_TEST_DIR_PATH + "/commons-text-1.4-bin.zip.sha256");
         File detachedBinZipSha512 = new File(COMMONS_RELEASE_PLUGIN_TEST_DIR_PATH + "/commons-text-1.4-bin.zip.sha512");
         File notDetachedMockAttachedFile = new File(COMMONS_RELEASE_PLUGIN_TEST_DIR_PATH + "/commons-text-1.4.jar");
-        File sha256Properties = new File(COMMONS_RELEASE_PLUGIN_TEST_DIR_PATH + "/sha256.properties");
         File sha512Properties = new File(COMMONS_RELEASE_PLUGIN_TEST_DIR_PATH + "/sha512.properties");
         assertTrue(detachedSrcTarGz.exists());
         assertTrue(detachedSrcTarGzAsc.exists());
-        assertTrue(detachedSrcTarGzSha256.exists());
         assertTrue(detachedSrcTarGzSha512.exists());
         assertTrue(detachedSrcZip.exists());
         assertTrue(detachedSrcZipAsc.exists());
-        assertTrue(detachedSrcZipSha256.exists());
         assertTrue(detachedSrcZipSha512.exists());
         assertTrue(detachedBinTarGz.exists());
         assertTrue(detachedBinTarGzAsc.exists());
-        assertTrue(detachedBinTarGzSha256.exists());
         assertTrue(detachedBinTarGzSha512.exists());
         assertTrue(detachedBinZip.exists());
         assertTrue(detachedBinZipAsc.exists());
-        assertTrue(detachedBinZipSha256.exists());
         assertTrue(detachedBinZipSha512.exists());
-        assertTrue(sha256Properties.exists());
         assertTrue(sha512Properties.exists());
         assertFalse(notDetachedMockAttachedFile.exists());
     }

http://git-wip-us.apache.org/repos/asf/commons-release-plugin/blob/7651f5bc/src/test/java/org/apache/commons/release/plugin/mojos/CommonsDistributionStagingMojoTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/release/plugin/mojos/CommonsDistributionStagingMojoTest.java b/src/test/java/org/apache/commons/release/plugin/mojos/CommonsDistributionStagingMojoTest.java
index 44b0ad2..1bca8c5 100755
--- a/src/test/java/org/apache/commons/release/plugin/mojos/CommonsDistributionStagingMojoTest.java
+++ b/src/test/java/org/apache/commons/release/plugin/mojos/CommonsDistributionStagingMojoTest.java
@@ -98,21 +98,17 @@ public class CommonsDistributionStagingMojoTest {
         File binariesHeaderHtml = new File(COMMONS_RELEASE_PLUGIN_TEST_DIR_PATH + "/scm/1.0-SNAPSHOT-RC1/binaries/HEADER.html");
         File binTar = new File(COMMONS_RELEASE_PLUGIN_TEST_DIR_PATH + "/scm/1.0-SNAPSHOT-RC1/binaries/commons-text-1.4-bin.tar.gz");
         File binTarASC = new File(COMMONS_RELEASE_PLUGIN_TEST_DIR_PATH + "/scm/1.0-SNAPSHOT-RC1/binaries/commons-text-1.4-bin.tar.gz.asc");
-        File binTarSha256 = new File(COMMONS_RELEASE_PLUGIN_TEST_DIR_PATH + "/scm/1.0-SNAPSHOT-RC1/binaries/commons-text-1.4-bin.tar.gz.sha256");
         File binTarSha512 = new File(COMMONS_RELEASE_PLUGIN_TEST_DIR_PATH + "/scm/1.0-SNAPSHOT-RC1/binaries/commons-text-1.4-bin.tar.gz.sha512");
         File binZip = new File(COMMONS_RELEASE_PLUGIN_TEST_DIR_PATH + "/scm/1.0-SNAPSHOT-RC1/binaries/commons-text-1.4-bin.zip");
         File binZipASC = new File(COMMONS_RELEASE_PLUGIN_TEST_DIR_PATH + "/scm/1.0-SNAPSHOT-RC1/binaries/commons-text-1.4-bin.zip.asc");
-        File binZipSha256 = new File(COMMONS_RELEASE_PLUGIN_TEST_DIR_PATH + "/scm/1.0-SNAPSHOT-RC1/binaries/commons-text-1.4-bin.zip.sha256");
         File binZipSha512 = new File(COMMONS_RELEASE_PLUGIN_TEST_DIR_PATH + "/scm/1.0-SNAPSHOT-RC1/binaries/commons-text-1.4-bin.zip.sha512");
         File sourcesReadmeHtml = new File(COMMONS_RELEASE_PLUGIN_TEST_DIR_PATH + "/scm/1.0-SNAPSHOT-RC1/binaries/README.html");
         File sourceHeaderHtml = new File(COMMONS_RELEASE_PLUGIN_TEST_DIR_PATH + "/scm/1.0-SNAPSHOT-RC1/binaries/HEADER.html");
         File srcTar = new File(COMMONS_RELEASE_PLUGIN_TEST_DIR_PATH + "/scm/1.0-SNAPSHOT-RC1/source/commons-text-1.4-src.tar.gz");
         File srcTarASC = new File(COMMONS_RELEASE_PLUGIN_TEST_DIR_PATH + "/scm/1.0-SNAPSHOT-RC1/source/commons-text-1.4-src.tar.gz.asc");
-        File srcTarSha256 = new File(COMMONS_RELEASE_PLUGIN_TEST_DIR_PATH + "/scm/1.0-SNAPSHOT-RC1/source/commons-text-1.4-src.tar.gz.sha256");
         File srcTarSha512 = new File(COMMONS_RELEASE_PLUGIN_TEST_DIR_PATH + "/scm/1.0-SNAPSHOT-RC1/source/commons-text-1.4-src.tar.gz.sha512");
         File srcZip = new File(COMMONS_RELEASE_PLUGIN_TEST_DIR_PATH + "/scm/1.0-SNAPSHOT-RC1/source/commons-text-1.4-src.zip");
         File srcZipASC = new File(COMMONS_RELEASE_PLUGIN_TEST_DIR_PATH + "/scm/1.0-SNAPSHOT-RC1/source/commons-text-1.4-src.zip.asc");
-        File srcZipSha256 = new File(COMMONS_RELEASE_PLUGIN_TEST_DIR_PATH + "/scm/1.0-SNAPSHOT-RC1/source/commons-text-1.4-src.zip.sha256");
         File srcZipSha512 = new File(COMMONS_RELEASE_PLUGIN_TEST_DIR_PATH + "/scm/1.0-SNAPSHOT-RC1/source/commons-text-1.4-src.zip.sha512");
         File site = new File(COMMONS_RELEASE_PLUGIN_TEST_DIR_PATH + "/scm/1.0-SNAPSHOT-RC1/site");
         File siteIndexHtml = new File(COMMONS_RELEASE_PLUGIN_TEST_DIR_PATH + "/scm/1.0-SNAPSHOT-RC1/site/index.html");
@@ -126,20 +122,16 @@ public class CommonsDistributionStagingMojoTest {
         assertTrue(binariesHeaderHtml.exists());
         assertTrue(binTar.exists());
         assertTrue(binTarASC.exists());
-        assertTrue(binTarSha256.exists());
         assertTrue(binTarSha512.exists());
         assertTrue(binZip.exists());
         assertTrue(binZipASC.exists());
-        assertTrue(binZipSha256.exists());
         assertTrue(sourcesReadmeHtml.exists());
         assertTrue(sourceHeaderHtml.exists());
         assertTrue(srcTar.exists());
         assertTrue(srcTarASC.exists());
-        assertTrue(srcTarSha256.exists());
         assertTrue(srcTarSha512.exists());
         assertTrue(srcZip.exists());
         assertTrue(srcZipASC.exists());
-        assertTrue(srcZipSha256.exists());
         assertTrue(srcZipSha512.exists());
         assertTrue(site.exists());
         assertTrue(siteIndexHtml.exists());