Skip to content
Permalink
Browse files
COMMONSSITE-117: remove md5 hashes from release artifacts
  • Loading branch information
chtompki committed Jun 15, 2018
1 parent b1bc7a3 commit d59a1c6f6ec5fbe3fb8bb0bdc4d885512d07b51c
Showing 5 changed files with 26 additions and 45 deletions.
@@ -24,6 +24,7 @@ o COMMONSSITE-108: Adding README.html and HEADER.html to staged release

CHANGES
=======
o COMMONSSITE-117: Remove md5 signatures from release artifacts.
o COMMONSSITE-113: Put unpacked site in scm dev dist directory for navigating purposes.
o Update platform requirement from Java 7 to Java 8.

@@ -25,7 +25,8 @@
</properties>

<body>
<release version="1.3" date="YYYY-MM-DD" description="TBD">
<release version="1.3" date="2018-06-15" description="Version 1.3">
<action issue="COMMONSSITE-117" type="update" dev="chtompki">Remove md5 signatures from release artifacts.</action>
<action issue="COMMONSSITE-113" type="update" dev="chtompki">Put unpacked site in scm dev dist directory for navigating purposes.</action>
<action issue="COMMONSSITE-112" type="add" dev="ggregory">Add a vote.txt file.</action>
<action issue="COMMONSSITE-108" type="add" dev="chtompki">Adding README.html and HEADER.html to staged release</action>
@@ -159,14 +159,9 @@ public void execute() throws MojoExecutionException {
*/
private void putAttachedArtifactInSha1Map(Artifact artifact) throws MojoExecutionException {
try {
StringBuffer artifactKey = new StringBuffer();
artifactKey
.append(artifact.getArtifactId()).append('-')
.append(artifact.getVersion()).append('-')
.append(artifact.getClassifier()).append('-')
.append(artifact.getType());
String artifactKey = getArtifactKey(artifact);
try (FileInputStream fis = new FileInputStream(artifact.getFile())) {
artifactSha1s.put(artifactKey.toString(), DigestUtils.sha1Hex(fis));
artifactSha1s.put(artifactKey, DigestUtils.sha1Hex(fis));
}
} catch (IOException e) {
throw new MojoExecutionException(
@@ -190,14 +185,9 @@ private void putAttachedArtifactInSha1Map(Artifact artifact) throws MojoExecutio
*/
private void putAttachedArtifactInSha256Map(Artifact artifact) throws MojoExecutionException {
try {
StringBuffer artifactKey = new StringBuffer();
artifactKey
.append(artifact.getArtifactId()).append('-')
.append(artifact.getVersion()).append('-')
.append(artifact.getClassifier()).append('-')
.append(artifact.getType());
String artifactKey = getArtifactKey(artifact);
try (FileInputStream fis = new FileInputStream(artifact.getFile())) {
artifactSha256s.put(artifactKey.toString(), DigestUtils.sha256Hex(fis));
artifactSha256s.put(artifactKey, DigestUtils.sha256Hex(fis));
}
} catch (IOException e) {
throw new MojoExecutionException(
@@ -277,22 +267,9 @@ private void copyRemovedArtifactsToWorkingDirectory() throws MojoExecutionExcept
private void hashArtifacts() throws MojoExecutionException {
for (Artifact artifact : detachedArtifacts) {
if (!artifact.getFile().getName().contains("asc")) {
StringBuffer artifactKey = new StringBuffer();
artifactKey.append(artifact.getArtifactId()).append('-')
.append(artifact.getVersion()).append('-')
.append(artifact.getClassifier()).append('-')
.append(artifact.getType());
String artifactKey = getArtifactKey(artifact);
try {
// MD5
String digest;
try (FileInputStream fis = new FileInputStream(artifact.getFile())) {
digest = DigestUtils.md5Hex(fis);
}
getLog().info(artifact.getFile().getName() + " md5: " + digest);
try (PrintWriter printWriter = new PrintWriter(
getMd5FilePath(workingDirectory, artifact.getFile()))) {
printWriter.println(digest);
}
// SHA-1
digest = artifactSha1s.getProperty(artifactKey.toString());
getLog().info(artifact.getFile().getName() + " sha1: " + digest);
@@ -358,4 +335,22 @@ private String getSha256FilePath(File directory, File file) {
buffer.append(".sha256");
return buffer.toString();
}

/**
* Generates the unique artifact key for storage in our sha1 map and sha256 map. For example,
* commons-test-1.4-src.tar.gz should have it's name as the key.
*
* @param artifact the {@link Artifact} that we wish to generate a key for.
* @return the generated key
*/
private String getArtifactKey(Artifact artifact) {
StringBuffer artifactKey = new StringBuffer();
artifactKey.append(artifact.getArtifactId()).append('-')
.append(artifact.getVersion()).append('-');
if (artifact.hasClassifier()) {
artifactKey.append(artifact.getClassifier()).append('-');
}
artifactKey.append(artifact.getType());
return artifactKey.toString();
}
}
@@ -67,45 +67,37 @@ public void testSuccess() throws Exception {
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 detachedSrcTarMd5 = new File(COMMONS_RELEASE_PLUGIN_TEST_DIR_PATH + "/commons-text-1.4-src.tar.gz.md5");
File detachedSrcTarGzSha1 = new File(COMMONS_RELEASE_PLUGIN_TEST_DIR_PATH + "/commons-text-1.4-src.tar.gz.sha1");
File detachedSrcTarGzSha256 = new File(COMMONS_RELEASE_PLUGIN_TEST_DIR_PATH + "/commons-text-1.4-src.tar.gz.sha256");
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 detachedSrcZipMd5 = new File(COMMONS_RELEASE_PLUGIN_TEST_DIR_PATH + "/commons-text-1.4-src.zip.md5");
File detachedSrcZipSha1 = new File(COMMONS_RELEASE_PLUGIN_TEST_DIR_PATH + "/commons-text-1.4-src.zip.sha1");
File detachedSrcZipSha256 = new File(COMMONS_RELEASE_PLUGIN_TEST_DIR_PATH + "/commons-text-1.4-src.zip.sha256");
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 detachedBinTarMd5 = new File(COMMONS_RELEASE_PLUGIN_TEST_DIR_PATH + "/commons-text-1.4-bin.tar.gz.md5");
File detachedBinTarGzSha1 = new File(COMMONS_RELEASE_PLUGIN_TEST_DIR_PATH + "/commons-text-1.4-bin.tar.gz.sha1");
File detachedBinTarGzSha256 = new File(COMMONS_RELEASE_PLUGIN_TEST_DIR_PATH + "/commons-text-1.4-bin.tar.gz.sha256");
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 detachedBinZipMd5 = new File(COMMONS_RELEASE_PLUGIN_TEST_DIR_PATH + "/commons-text-1.4-bin.zip.md5");
File detachedBinZipSha1 = new File(COMMONS_RELEASE_PLUGIN_TEST_DIR_PATH + "/commons-text-1.4-bin.zip.sha1");
File detachedBinZipSha256 = new File(COMMONS_RELEASE_PLUGIN_TEST_DIR_PATH + "/commons-text-1.4-bin.zip.sha256");
File notDetachedMockAttachedFile = new File(COMMONS_RELEASE_PLUGIN_TEST_DIR_PATH + "/commons-text-1.4.jar");
File sha1Properties = new File(COMMONS_RELEASE_PLUGIN_TEST_DIR_PATH + "/sha1.properties");
File sha256Properties = new File(COMMONS_RELEASE_PLUGIN_TEST_DIR_PATH + "/sha256.properties");
assertTrue(detachedSrcTarGz.exists());
assertTrue(detachedSrcTarGzAsc.exists());
assertTrue(detachedSrcTarMd5.exists());
assertTrue(detachedSrcTarGzSha1.exists());
assertTrue(detachedSrcTarGzSha256.exists());
assertTrue(detachedSrcZip.exists());
assertTrue(detachedSrcZipAsc.exists());
assertTrue(detachedSrcZipMd5.exists());
assertTrue(detachedSrcZipSha1.exists());
assertTrue(detachedSrcZipSha256.exists());
assertTrue(detachedBinTarGz.exists());
assertTrue(detachedBinTarGzAsc.exists());
assertTrue(detachedBinTarMd5.exists());
assertTrue(detachedBinTarGzSha1.exists());
assertTrue(detachedBinTarGzSha256.exists());
assertTrue(detachedBinZip.exists());
assertTrue(detachedBinZipAsc.exists());
assertTrue(detachedBinZipMd5.exists());
assertTrue(detachedBinZipSha1.exists());
assertTrue(detachedBinZipSha256.exists());
assertTrue(sha1Properties.exists());
@@ -98,24 +98,20 @@ private void assertRequisiteFilesExist() {
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 binTarMD5 = new File(COMMONS_RELEASE_PLUGIN_TEST_DIR_PATH + "/scm/1.0-SNAPSHOT-RC1/binaries/commons-text-1.4-bin.tar.gz.md5");
File binTarSHA1 = new File(COMMONS_RELEASE_PLUGIN_TEST_DIR_PATH + "/scm/1.0-SNAPSHOT-RC1/binaries/commons-text-1.4-bin.tar.gz.sha1");
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 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 binZipMD5 = new File(COMMONS_RELEASE_PLUGIN_TEST_DIR_PATH + "/scm/1.0-SNAPSHOT-RC1/binaries/commons-text-1.4-bin.zip.md5");
File binZipSHA1 = new File(COMMONS_RELEASE_PLUGIN_TEST_DIR_PATH + "/scm/1.0-SNAPSHOT-RC1/binaries/commons-text-1.4-bin.zip.sha1");
File binZipSHA256 = new File(COMMONS_RELEASE_PLUGIN_TEST_DIR_PATH + "/scm/1.0-SNAPSHOT-RC1/binaries/commons-text-1.4-bin.zip.sha256");
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 srcTarMD5 = new File(COMMONS_RELEASE_PLUGIN_TEST_DIR_PATH + "/scm/1.0-SNAPSHOT-RC1/source/commons-text-1.4-src.tar.gz.md5");
File srcTarSHA1 = new File(COMMONS_RELEASE_PLUGIN_TEST_DIR_PATH + "/scm/1.0-SNAPSHOT-RC1/source/commons-text-1.4-src.tar.gz.sha1");
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 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 srcZipMD5 = new File(COMMONS_RELEASE_PLUGIN_TEST_DIR_PATH + "/scm/1.0-SNAPSHOT-RC1/source/commons-text-1.4-src.zip.md5");
File srcZipSHA1 = new File(COMMONS_RELEASE_PLUGIN_TEST_DIR_PATH + "/scm/1.0-SNAPSHOT-RC1/source/commons-text-1.4-src.zip.sha1");
File srcZipSHA256 = new File(COMMONS_RELEASE_PLUGIN_TEST_DIR_PATH + "/scm/1.0-SNAPSHOT-RC1/source/commons-text-1.4-src.zip.sha256");
File site = new File(COMMONS_RELEASE_PLUGIN_TEST_DIR_PATH + "/scm/1.0-SNAPSHOT-RC1/site");
@@ -130,24 +126,20 @@ private void assertRequisiteFilesExist() {
assertTrue(binariesHeaderHtml.exists());
assertTrue(binTar.exists());
assertTrue(binTarASC.exists());
assertTrue(binTarMD5.exists());
assertTrue(binTarSHA1.exists());
assertTrue(binTarSHA256.exists());
assertTrue(binZip.exists());
assertTrue(binZipASC.exists());
assertTrue(binZipMD5.exists());
assertTrue(binZipSHA1.exists());
assertTrue(binZipSHA256.exists());
assertTrue(sourcesReadmeHtml.exists());
assertTrue(sourceHeaderHtml.exists());
assertTrue(srcTar.exists());
assertTrue(srcTarASC.exists());
assertTrue(srcTarMD5.exists());
assertTrue(srcTarSHA1.exists());
assertTrue(srcTarSHA256.exists());
assertTrue(srcZip.exists());
assertTrue(srcZipASC.exists());
assertTrue(srcZipMD5.exists());
assertTrue(srcZipSHA1.exists());
assertTrue(srcZipSHA256.exists());
assertTrue(site.exists());

0 comments on commit d59a1c6

Please sign in to comment.