Skip to content

Commit

Permalink
MJAR-263 make output jars reproducible like m-source-p
Browse files Browse the repository at this point in the history
  • Loading branch information
hboutemy committed Oct 29, 2019
1 parent 80f58a8 commit 64c5e65
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 9 deletions.
17 changes: 8 additions & 9 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
</parent>

<artifactId>maven-jar-plugin</artifactId>
<version>3.1.3-SNAPSHOT</version>
<version>3.2.0-SNAPSHOT</version>
<packaging>maven-plugin</packaging>

<name>Apache Maven JAR Plugin</name>
Expand Down Expand Up @@ -76,7 +76,7 @@

<properties>
<mavenFileManagementVersion>3.0.0</mavenFileManagementVersion>
<mavenArchiverVersion>3.4.0</mavenArchiverVersion>
<mavenArchiverVersion>3.5.0</mavenArchiverVersion>
<mavenVersion>3.0</mavenVersion>
<javaVersion>7</javaVersion>
</properties>
Expand Down Expand Up @@ -133,13 +133,13 @@
<dependency>
<groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-archiver</artifactId>
<version>4.1.0</version>
<version>4.2.1</version>
</dependency>
<dependency>
<groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-utils</artifactId>
<version>3.2.0</version>
</dependency>
<dependency>
<groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-utils</artifactId>
<version>3.3.0</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
Expand Down Expand Up @@ -199,7 +199,6 @@
<goal>clean</goal>
<goal>package</goal>
</goals>
<streamLogs>true</streamLogs>
<showErrors>true</showErrors>
</configuration>
<executions>
Expand Down
14 changes: 14 additions & 0 deletions src/main/java/org/apache/maven/plugins/jar/AbstractJarMojo.java
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,16 @@ public abstract class AbstractJarMojo
@Parameter( defaultValue = "false" )
private boolean skipIfEmpty;

/**
* 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.2.0
*/
@Parameter( defaultValue = "${project.build.outputTimestamp}" )
private String outputTimestamp;

/**
* Return the specific output directory to serve as the root for the archive.
* @return get classes directory.
Expand Down Expand Up @@ -233,6 +243,7 @@ public File createArchive()
}

MavenArchiver archiver = new MavenArchiver();
archiver.setCreatedBy( "Maven Jar Plugin", "org.apache.maven.plugins", "maven-jar-plugin" );

if ( containsModuleDescriptor )
{
Expand All @@ -245,6 +256,9 @@ public File createArchive()

archiver.setOutputFile( jarFile );

// configure for Reproducible Builds based on outputTimestamp value
archiver.configureReproducible( outputTimestamp );

archive.setForced( forceCreation );

try
Expand Down

0 comments on commit 64c5e65

Please sign in to comment.