diff --git a/pom.xml b/pom.xml index 9c05f0b..dbb1d33 100644 --- a/pom.xml +++ b/pom.xml @@ -30,7 +30,7 @@ maven-jar-plugin - 3.1.3-SNAPSHOT + 3.2.0-SNAPSHOT maven-plugin Apache Maven JAR Plugin @@ -76,7 +76,7 @@ 3.0.0 - 3.4.0 + 3.5.0 3.0 7 @@ -133,13 +133,13 @@ org.codehaus.plexus plexus-archiver - 4.1.0 + 4.2.1 - - org.codehaus.plexus - plexus-utils - 3.2.0 - + + org.codehaus.plexus + plexus-utils + 3.3.0 + junit junit @@ -199,7 +199,6 @@ clean package - true true diff --git a/src/main/java/org/apache/maven/plugins/jar/AbstractJarMojo.java b/src/main/java/org/apache/maven/plugins/jar/AbstractJarMojo.java index 2763350..68da0ec 100644 --- a/src/main/java/org/apache/maven/plugins/jar/AbstractJarMojo.java +++ b/src/main/java/org/apache/maven/plugins/jar/AbstractJarMojo.java @@ -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 + * yyyy-MM-dd'T'HH:mm:ssXXX or as an int representing seconds since the epoch (like + * SOURCE_DATE_EPOCH). + * + * @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. @@ -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 ) { @@ -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