This is an automated email from the ASF dual-hosted git repository.

ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-release-plugin.git


The following commit(s) were added to refs/heads/master by this push:
     new b5fcd34  Create signature validation script for releases.
b5fcd34 is described below

commit b5fcd34e2730a400712203b3ccdc24a3e1ff48af
Author: Gary Gregory <garydgreg...@gmail.com>
AuthorDate: Sat Feb 6 13:41:37 2021 -0500

    Create signature validation script for releases.
    
    The source can be in a local file or inside a jar file.
---
 src/changes/changes.xml                            |  2 +-
 .../mojos/CommonsDistributionStagingMojo.java      | 31 +++++++++++++---------
 2 files changed, 19 insertions(+), 14 deletions(-)

diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index ca255c3..aea873c 100755
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -29,7 +29,7 @@
       <action type="update" dev="kinow">Bump maven-checkstyle-plugin from 
3.1.1 to 3.1.2 #36.</action>
       <action type="update" dev="kinow">Bump maven-pmd-plugin from 3.13.0 to 
3.14.0 #29.</action>
       <action type="update" dev="kinow">Bump commons-build-plugin from 1.11 to 
1.12 #25.</action>
-      <action issue="COMMONSSITE-138" type="add" dev="chtompki">Create 
signature validation script for releases</action>
+      <action issue="COMMONSSITE-138" type="add" dev="chtompki, 
ggregory">Create signature validation script for releases.</action>
       <action type="update" dev="kinow">Bump actions/setup-java from v1.4.0 to 
v1.4.3 #11 #19.</action>
       <action type="update" dev="kinow">Bump spotbugs from 4.1.1 to 4.2.1 #10 
#24 #30 #37.</action>
       <action type="update" dev="kinow">Bump spotbugs-maven-plugin from 4.1.1 
to 4.2.0 #20 #26 #33.</action>
diff --git 
a/src/main/java/org/apache/commons/release/plugin/mojos/CommonsDistributionStagingMojo.java
 
b/src/main/java/org/apache/commons/release/plugin/mojos/CommonsDistributionStagingMojo.java
index 48b7a44..633d3ff 100755
--- 
a/src/main/java/org/apache/commons/release/plugin/mojos/CommonsDistributionStagingMojo.java
+++ 
b/src/main/java/org/apache/commons/release/plugin/mojos/CommonsDistributionStagingMojo.java
@@ -16,7 +16,19 @@
  */
 package org.apache.commons.release.plugin.mojos;
 
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.io.OutputStreamWriter;
+import java.io.Writer;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
 import org.apache.commons.io.FileUtils;
+import org.apache.commons.io.IOUtils;
 import org.apache.commons.lang3.StringUtils;
 import org.apache.commons.release.plugin.SharedFunctions;
 import org.apache.commons.release.plugin.velocity.HeaderHtmlVelocityDelegate;
@@ -44,15 +56,6 @@ import org.apache.maven.scm.repository.ScmRepository;
 import org.apache.maven.settings.Settings;
 import org.apache.maven.settings.crypto.SettingsDecrypter;
 
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.OutputStreamWriter;
-import java.io.Writer;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-
 /**
  * This class checks out the dev distribution location, copies the 
distributions into that directory
  * structure under the <code>target/commons-release-plugin/scm</code> 
directory. Then commits the
@@ -381,11 +384,13 @@ public class CommonsDistributionStagingMojo extends 
AbstractMojo {
     private List<File> copySignatureValidatorScriptToScmDirectory() throws 
MojoExecutionException {
         final File signatureValidatorFileInScm = new 
File(distVersionRcVersionDirectory, SIGNATURE_VALIDATOR_FILE_NAME);
         final String resourceName = "/resources/" + 
SIGNATURE_VALIDATOR_FILE_NAME;
-        try {
-            final File signatureValidatorFileInJar = new 
File(this.getClass().getResource(resourceName).getFile());
-            FileUtils.copyFile(signatureValidatorFileInJar, 
signatureValidatorFileInScm);
+        // The source can be in a local file or inside a jar file.
+        try (InputStream inputStream = 
getClass().getResource(resourceName).openStream();
+            OutputStream outputStream = new 
FileOutputStream(signatureValidatorFileInScm)) {
+            IOUtils.copy(inputStream, outputStream);
         } catch (final Exception e) {
-            throw new MojoExecutionException("Failed to copy " + resourceName, 
e);
+            throw new MojoExecutionException(
+                String.format("Failed to copy '%s' to '%s'", resourceName, 
signatureValidatorFileInScm), e);
         }
         final List<File> signatureFileInList = new ArrayList<>();
         signatureFileInList.add(signatureValidatorFileInScm);

Reply via email to