maven-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rfscho...@apache.org
Subject [maven-jarsigner] 01/01: [MSHARED-764] Upgrade to JDK 1.7 Apply try-with-resources Fix Javadoc Use maven-jxr-plugin 3.0.0 for for improved reports
Date Fri, 26 Oct 2018 09:43:55 GMT
This is an automated email from the ASF dual-hosted git repository.

rfscholte pushed a commit to branch MSHARED-764
in repository https://gitbox.apache.org/repos/asf/maven-jarsigner.git

commit 1810f80c9f949ddffd29fb18f817f4c5ba4b36ef
Author: rfscholte <rfscholte@apache.org>
AuthorDate: Fri Oct 26 11:43:49 2018 +0200

    [MSHARED-764] Upgrade to JDK 1.7
    Apply try-with-resources
    Fix Javadoc
    Use maven-jxr-plugin 3.0.0 for for improved reports
---
 pom.xml                                            | 10 ++--
 .../shared/jarsigner/AbstractJarSignerRequest.java |  3 +-
 .../CommandLineConfigurationException.java         |  3 +-
 .../maven/shared/jarsigner/DefaultJarSigner.java   |  3 +-
 .../apache/maven/shared/jarsigner/JarSigner.java   |  3 +-
 .../jarsigner/JarSignerCommandLineBuilder.java     |  3 +-
 .../maven/shared/jarsigner/JarSignerRequest.java   |  6 +--
 .../shared/jarsigner/JarSignerSignRequest.java     |  3 +-
 .../maven/shared/jarsigner/JarSignerUtil.java      | 56 ++++------------------
 .../shared/jarsigner/JarSignerVerifyRequest.java   |  3 +-
 .../maven/shared/jarsigner/JarSignerUtilTest.java  |  3 +-
 11 files changed, 27 insertions(+), 69 deletions(-)

diff --git a/pom.xml b/pom.xml
index 26c72d8..8ba75c8 100644
--- a/pom.xml
+++ b/pom.xml
@@ -24,7 +24,7 @@
     <groupId>org.apache.maven.shared</groupId>
     <artifactId>maven-shared-components</artifactId>
     <version>33</version>
-    <relativePath>../../pom/maven/maven-shared-components/pom.xml</relativePath>
+    <relativePath/>
   </parent>
 
   <artifactId>maven-jarsigner</artifactId>
@@ -61,6 +61,7 @@
   <properties>
     <surefire.version>2.21.0</surefire.version>
     <mavenVersion>3.0</mavenVersion>
+    <javaVersion>7</javaVersion>
   </properties>
 
   <dependencies>
@@ -73,7 +74,6 @@
     <dependency>
       <groupId>org.codehaus.plexus</groupId>
       <artifactId>plexus-component-annotations</artifactId>
-      <version>1.6</version>
     </dependency>
 
     <dependency>
@@ -109,13 +109,17 @@
             </excludes>
           </configuration>
         </plugin>
+        <plugin>
+          <groupId>org.apache.maven.plugins</groupId>
+          <artifactId>maven-jxr-plugin</artifactId>
+          <version>3.0.0</version>
+        </plugin>
       </plugins>
     </pluginManagement>
     <plugins>
       <plugin>
         <groupId>org.codehaus.plexus</groupId>
         <artifactId>plexus-component-metadata</artifactId>
-        <version>1.7.1</version>
         <executions>
           <execution>
             <id>create-component-descriptor</id>
diff --git a/src/main/java/org/apache/maven/shared/jarsigner/AbstractJarSignerRequest.java
b/src/main/java/org/apache/maven/shared/jarsigner/AbstractJarSignerRequest.java
index ca25fbc..1fb0527 100644
--- a/src/main/java/org/apache/maven/shared/jarsigner/AbstractJarSignerRequest.java
+++ b/src/main/java/org/apache/maven/shared/jarsigner/AbstractJarSignerRequest.java
@@ -26,8 +26,7 @@ import java.io.File;
 /**
  * Specifies the commons parameters used to control a jar signer invocation.
  *
- * @author tchemit <chemit@codelutin.com>
- * @version $Id$
+ * @author Tony Chemit
  * @since 1.0
  */
 public abstract class AbstractJarSignerRequest
diff --git a/src/main/java/org/apache/maven/shared/jarsigner/CommandLineConfigurationException.java
b/src/main/java/org/apache/maven/shared/jarsigner/CommandLineConfigurationException.java
index 9c8d21f..d44a756 100644
--- a/src/main/java/org/apache/maven/shared/jarsigner/CommandLineConfigurationException.java
+++ b/src/main/java/org/apache/maven/shared/jarsigner/CommandLineConfigurationException.java
@@ -22,8 +22,7 @@ package org.apache.maven.shared.jarsigner;
 /**
  * Signals an error during the construction of the command line used to invoke jar signer.
  *
- * @author tchemit <chemit@codelutin.com>
- * @version $Id$
+ * @author Tony Chemit
  * @since 1.0
  */
 public class CommandLineConfigurationException
diff --git a/src/main/java/org/apache/maven/shared/jarsigner/DefaultJarSigner.java b/src/main/java/org/apache/maven/shared/jarsigner/DefaultJarSigner.java
index 95a4c66..e789674 100644
--- a/src/main/java/org/apache/maven/shared/jarsigner/DefaultJarSigner.java
+++ b/src/main/java/org/apache/maven/shared/jarsigner/DefaultJarSigner.java
@@ -28,8 +28,7 @@ import org.codehaus.plexus.component.annotations.Component;
 /**
  * Default implementation of component {@link JarSigner}.
  *
- * @author tchemit <chemit@codelutin.com>
- * @version $Id$
+ * @author Tony Chemit
  * @since 1.0
  */
 @Component( role = JarSigner.class, hint = "default" )
diff --git a/src/main/java/org/apache/maven/shared/jarsigner/JarSigner.java b/src/main/java/org/apache/maven/shared/jarsigner/JarSigner.java
index c56a563..9cdc534 100644
--- a/src/main/java/org/apache/maven/shared/jarsigner/JarSigner.java
+++ b/src/main/java/org/apache/maven/shared/jarsigner/JarSigner.java
@@ -24,8 +24,7 @@ import org.apache.maven.shared.utils.cli.javatool.JavaTool;
 /**
  * Provides a facade to invoke JarSigner tool.
  *
- * @author tchemit <chemit@codelutin.com>
- * @version $Id$
+ * @author Tony Chemit
  * @since 1.0
  */
 public interface JarSigner
diff --git a/src/main/java/org/apache/maven/shared/jarsigner/JarSignerCommandLineBuilder.java
b/src/main/java/org/apache/maven/shared/jarsigner/JarSignerCommandLineBuilder.java
index d8b6da5..0be0308 100644
--- a/src/main/java/org/apache/maven/shared/jarsigner/JarSignerCommandLineBuilder.java
+++ b/src/main/java/org/apache/maven/shared/jarsigner/JarSignerCommandLineBuilder.java
@@ -31,8 +31,7 @@ import java.io.IOException;
 /**
  * To build the command line for a given {@link JarSignerRequest}.
  *
- * @author tchemit <chemit@codelutin.com>
- * @version $Id$
+ * @author Tony Chemit
  * @since 1.0
  */
 public class JarSignerCommandLineBuilder
diff --git a/src/main/java/org/apache/maven/shared/jarsigner/JarSignerRequest.java b/src/main/java/org/apache/maven/shared/jarsigner/JarSignerRequest.java
index 3fa30c6..1ef819d 100644
--- a/src/main/java/org/apache/maven/shared/jarsigner/JarSignerRequest.java
+++ b/src/main/java/org/apache/maven/shared/jarsigner/JarSignerRequest.java
@@ -26,8 +26,7 @@ import java.io.File;
 /**
  * Specifies the common parameters used to control a JarSigner tool invocation.
  *
- * @author tchemit <chemit@codelutin.com>
- * @version $Id$
+ * @author Tony Chemit
  * @since 1.0
  */
 public interface JarSignerRequest
@@ -113,8 +112,9 @@ public interface JarSignerRequest
 
     /**
      * Gets the value of the {@code archive} field.
-     * <p/>
+     * <p>
      * The archive field is in fact the file on which the jarsigner request will be executed.
+     * </p>
      *
      * @return the value of the {@code archive} field.
      */
diff --git a/src/main/java/org/apache/maven/shared/jarsigner/JarSignerSignRequest.java b/src/main/java/org/apache/maven/shared/jarsigner/JarSignerSignRequest.java
index 214539d..5064523 100644
--- a/src/main/java/org/apache/maven/shared/jarsigner/JarSignerSignRequest.java
+++ b/src/main/java/org/apache/maven/shared/jarsigner/JarSignerSignRequest.java
@@ -24,8 +24,7 @@ import java.io.File;
 /**
  * Specifies the parameters used to control a jar signer sign operation invocation.
  *
- * @author tchemit <chemit@codelutin.com>
- * @version $Id$
+ * @author Tony Chemit
  * @since 1.0
  */
 public class JarSignerSignRequest
diff --git a/src/main/java/org/apache/maven/shared/jarsigner/JarSignerUtil.java b/src/main/java/org/apache/maven/shared/jarsigner/JarSignerUtil.java
index e8a0826..c0521d2 100644
--- a/src/main/java/org/apache/maven/shared/jarsigner/JarSignerUtil.java
+++ b/src/main/java/org/apache/maven/shared/jarsigner/JarSignerUtil.java
@@ -38,8 +38,7 @@ import java.util.zip.ZipOutputStream;
 /**
  * Useful methods.
  *
- * @author tchemit <chemit@codelutin.com>
- * @version $Id$
+ * @author Tony Chemit
  * @since 1.0
  */
 public class JarSignerUtil
@@ -60,17 +59,10 @@ public class JarSignerUtil
     public static boolean isZipFile( final File file )
     {
         boolean result = false;
-        try
+
+        try ( ZipInputStream zis = new ZipInputStream( new FileInputStream( file ) ) )
         {
-            ZipInputStream zis = new ZipInputStream( new FileInputStream( file ) );
-            try
-            {
-                result = zis.getNextEntry() != null;
-            }
-            finally
-            {
-                zis.close();
-            }
+            result = zis.getNextEntry() != null;
         }
         catch ( Exception e )
         {
@@ -85,7 +77,7 @@ public class JarSignerUtil
      * output JAR to retain as much metadata from the original JAR as possible.
      *
      * @param jarFile The JAR file to unsign, must not be <code>null</code>.
-     * @throws IOException
+     * @throws IOException when error occurs during processing the file
      */
     public static void unsignArchive( File jarFile )
         throws IOException
@@ -93,13 +85,10 @@ public class JarSignerUtil
 
         File unsignedFile = new File( jarFile.getAbsolutePath() + ".unsigned" );
 
-        ZipInputStream zis = null;
-        ZipOutputStream zos = null;
-        try
+        try ( ZipInputStream zis = new ZipInputStream( new BufferedInputStream( new FileInputStream(
jarFile ) ) );
+                        ZipOutputStream zos =
+                            new ZipOutputStream( new BufferedOutputStream( new FileOutputStream(
unsignedFile ) ) ) )
         {
-            zis = new ZipInputStream( new BufferedInputStream( new FileInputStream( jarFile
) ) );
-            zos = new ZipOutputStream( new BufferedOutputStream( new FileOutputStream( unsignedFile
) ) );
-
             for ( ZipEntry ze = zis.getNextEntry(); ze != null; ze = zis.getNextEntry() )
             {
                 if ( isSignatureFile( ze.getName() ) )
@@ -125,11 +114,6 @@ public class JarSignerUtil
             }
 
         }
-        finally
-        {
-            IOUtil.close( zis );
-            IOUtil.close( zos );
-        }
 
         FileUtils.rename( unsignedFile, jarFile );
 
@@ -191,13 +175,9 @@ public class JarSignerUtil
             throw new NullPointerException( "jarFile" );
         }
 
-        ZipInputStream in = null;
-        boolean suppressExceptionOnClose = true;
-
-        try
+        try ( ZipInputStream in = new ZipInputStream( new BufferedInputStream( new FileInputStream(
jarFile ) ) ) )
         {
             boolean signed = false;
-            in = new ZipInputStream( new BufferedInputStream( new FileInputStream( jarFile
) ) );
 
             for ( ZipEntry ze = in.getNextEntry(); ze != null; ze = in.getNextEntry() )
             {
@@ -208,26 +188,8 @@ public class JarSignerUtil
                 }
             }
 
-            suppressExceptionOnClose = false;
             return signed;
         }
-        finally
-        {
-            try
-            {
-                if ( in != null )
-                {
-                    in.close();
-                }
-            }
-            catch ( IOException e )
-            {
-                if ( !suppressExceptionOnClose )
-                {
-                    throw e;
-                }
-            }
-        }
     }
 
     /**
diff --git a/src/main/java/org/apache/maven/shared/jarsigner/JarSignerVerifyRequest.java b/src/main/java/org/apache/maven/shared/jarsigner/JarSignerVerifyRequest.java
index 5c5d310..7e94288 100644
--- a/src/main/java/org/apache/maven/shared/jarsigner/JarSignerVerifyRequest.java
+++ b/src/main/java/org/apache/maven/shared/jarsigner/JarSignerVerifyRequest.java
@@ -22,8 +22,7 @@ package org.apache.maven.shared.jarsigner;
 /**
  * Specifies the parameters used to control a jar signer verify operation invocation.
  *
- * @author tchemit <chemit@codelutin.com>
- * @version $Id$
+ * @author Tony Chemit
  * @since 1.0
  */
 public class JarSignerVerifyRequest
diff --git a/src/test/java/org/apache/maven/shared/jarsigner/JarSignerUtilTest.java b/src/test/java/org/apache/maven/shared/jarsigner/JarSignerUtilTest.java
index 8357534..e6a84da 100644
--- a/src/test/java/org/apache/maven/shared/jarsigner/JarSignerUtilTest.java
+++ b/src/test/java/org/apache/maven/shared/jarsigner/JarSignerUtilTest.java
@@ -29,8 +29,7 @@ import java.util.jar.Manifest;
 /**
  * Created on 11/8/13.
  *
- * @author Tony Chemit <chemit@codelutin.com>
- * @version $Id$
+ * @author Tony Chemit
  * @since 1.1
  */
 public class JarSignerUtilTest


Mime
View raw message