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

hboutemy pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/maven-ejb-plugin.git


The following commit(s) were added to refs/heads/master by this push:
     new 7c58d98  [MEJB-128] support Reproducible jar creation based on 
outputTimestamp
7c58d98 is described below

commit 7c58d98d8175191b7d9d18214a6d4319aa3da96f
Author: Hervé Boutemy <hbout...@apache.org>
AuthorDate: Sun May 10 19:21:32 2020 +0200

    [MEJB-128] support Reproducible jar creation based on outputTimestamp
---
 pom.xml                                            |  4 ++--
 src/it/default/pom.xml                             |  1 +
 src/it/manifest-content/verify.bsh                 |  4 ++--
 .../java/org/apache/maven/plugins/ejb/EjbMojo.java | 25 +++++++++++++++++++---
 4 files changed, 27 insertions(+), 7 deletions(-)

diff --git a/pom.xml b/pom.xml
index e86d183..0b52c61 100644
--- a/pom.xml
+++ b/pom.xml
@@ -30,7 +30,7 @@ under the License.
   </parent>
 
   <artifactId>maven-ejb-plugin</artifactId>
-  <version>3.0.2-SNAPSHOT</version>
+  <version>3.1.0-SNAPSHOT</version>
   <packaging>maven-plugin</packaging>
 
   <name>Apache Maven EJB Plugin</name>
@@ -62,7 +62,7 @@ under the License.
   </distributionManagement>
 
   <properties>
-    <mavenArchiverVersion>3.2.0</mavenArchiverVersion>
+    <mavenArchiverVersion>3.5.0</mavenArchiverVersion>
     <mavenFilteringVersion>3.1.1</mavenFilteringVersion>
     <mavenVersion>3.1.1</mavenVersion>
     <javaVersion>7</javaVersion>
diff --git a/src/it/default/pom.xml b/src/it/default/pom.xml
index 3cd061d..b2618e5 100644
--- a/src/it/default/pom.xml
+++ b/src/it/default/pom.xml
@@ -38,6 +38,7 @@ under the License.
 
   <properties>
     <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+    
<project.build.outputTimestamp>2020-05-01T12:12:12Z</project.build.outputTimestamp>
   </properties>
 
   <build>
diff --git a/src/it/manifest-content/verify.bsh 
b/src/it/manifest-content/verify.bsh
index c1a7aed..190d22c 100644
--- a/src/it/manifest-content/verify.bsh
+++ b/src/it/manifest-content/verify.bsh
@@ -33,9 +33,9 @@ JarFile jar = new JarFile( jarFile );
 
 Attributes manifest = jar.getManifest().getMainAttributes();
 
-if ( !manifest.getValue( new Attributes.Name( "Created-By" ) ).startsWith( 
"Apache Maven" ) )
+if ( !manifest.getValue( new Attributes.Name( "Created-By" ) ).startsWith( 
"Maven EJB Plugin" ) )
 {
-    throw new IllegalStateException( "Created-By not equals Apache Maven" );
+    throw new IllegalStateException( "Created-By not equals Maven EJB Plugin" 
);
 }
 
 String classpath = manifest.getValue( Attributes.Name.CLASS_PATH );
diff --git a/src/main/java/org/apache/maven/plugins/ejb/EjbMojo.java 
b/src/main/java/org/apache/maven/plugins/ejb/EjbMojo.java
index e1a2826..205f937 100644
--- a/src/main/java/org/apache/maven/plugins/ejb/EjbMojo.java
+++ b/src/main/java/org/apache/maven/plugins/ejb/EjbMojo.java
@@ -55,9 +55,8 @@ import org.codehaus.plexus.util.FileUtils;
  * @author <a href="eveni...@apache.org">Emmanuel Venisse</a>
  * @version $Id$
  */
-// CHECKSTYLE_OFF: LineLength
-@Mojo( name = "ejb", requiresDependencyResolution = ResolutionScope.RUNTIME, 
threadSafe = true, defaultPhase = LifecyclePhase.PACKAGE )
-// CHECKSTYLE_ON: LineLength
+@Mojo( name = "ejb", requiresDependencyResolution = ResolutionScope.RUNTIME, 
threadSafe = true,
+                defaultPhase = LifecyclePhase.PACKAGE )
 public class EjbMojo
     extends AbstractMojo
 {
@@ -272,6 +271,16 @@ public class EjbMojo
     @Parameter( defaultValue = "${session}", readonly = true, required = true )
     private MavenSession session;
 
+    /**
+     * Timestamp for reproducible output archive entries, either formatted as 
ISO 8601
+     * <code>yyyy-MM-dd'T'HH:mm:ssXXX</code> or as an int representing seconds 
since the epoch (like
+     * <a 
href="https://reproducible-builds.org/docs/source-date-epoch/";>SOURCE_DATE_EPOCH</a>).
+     *
+     * @since 3.1.0
+     */
+    @Parameter( defaultValue = "${project.build.outputTimestamp}" )
+    private String outputTimestamp;
+
     private static final String EJB_TYPE = "ejb";
 
     private static final String EJB_CLIENT_TYPE = "ejb-client";
@@ -363,8 +372,13 @@ public class EjbMojo
 
         archiver.setArchiver( jarArchiver );
 
+        archiver.setCreatedBy( "Maven EJB Plugin", "org.apache.maven.plugins", 
"maven-ejb-plugin" );
+
         archiver.setOutputFile( jarFile );
 
+        // configure for Reproducible Builds based on outputTimestamp value
+        archiver.configureReproducible( outputTimestamp );
+
         File deploymentDescriptor = new File( sourceDirectory, ejbJar );
 
         checkEJBVersionCompliance( deploymentDescriptor );
@@ -418,8 +432,13 @@ public class EjbMojo
 
         clientArchiver.setArchiver( clientJarArchiver );
 
+        clientArchiver.setCreatedBy( "Maven EJB Plugin", 
"org.apache.maven.plugins", "maven-ejb-plugin" );
+
         clientArchiver.setOutputFile( clientJarFile );
 
+        // configure for Reproducible Builds based on outputTimestamp value
+        clientArchiver.configureReproducible( outputTimestamp );
+
         try
         {
             List<String> defaultExcludes = DEFAULT_CLIENT_EXCLUDES_LIST;

Reply via email to