diff --git a/pom.xml b/pom.xml index 556df16e..67efc681 100644 --- a/pom.xml +++ b/pom.xml @@ -30,7 +30,7 @@ under the License. maven-site-plugin - 3.8.3-SNAPSHOT + 3.9.0-SNAPSHOT maven-plugin Apache Maven Site Plugin @@ -283,7 +283,7 @@ under the License. org.apache.maven maven-archiver - 3.1.1 + 3.5.0 @@ -302,7 +302,7 @@ under the License. org.codehaus.plexus plexus-archiver - 3.4 + 4.2.1 @@ -319,7 +319,7 @@ under the License. org.codehaus.plexus plexus-utils - 3.0.24 + 3.3.0 diff --git a/src/it/projects/site-jar/pom.xml b/src/it/projects/site-jar/pom.xml index dcd739ff..d76a8eaf 100644 --- a/src/it/projects/site-jar/pom.xml +++ b/src/it/projects/site-jar/pom.xml @@ -34,6 +34,7 @@ under the License. 2.0.7 UTF-8 + 2019-11-02T17:48:12Z diff --git a/src/it/projects/site-jar/verify.bsh b/src/it/projects/site-jar/verify.bsh index d28a2421..c512531b 100644 --- a/src/it/projects/site-jar/verify.bsh +++ b/src/it/projects/site-jar/verify.bsh @@ -50,6 +50,11 @@ try while ( jarEntries.hasMoreElements() ) { JarEntry entry = (JarEntry) jarEntries.nextElement(); + if ( entry.getTime() != 1572713292000L ) + { + System.out.println( "wrong entry time for " + entry.getName() + ": " + entry.getTime() ); + return false; + } if ( !entry.isDirectory() ) { // Only compare files diff --git a/src/main/java/org/apache/maven/plugins/site/render/SiteJarMojo.java b/src/main/java/org/apache/maven/plugins/site/render/SiteJarMojo.java index 211eb6a1..26be6d40 100644 --- a/src/main/java/org/apache/maven/plugins/site/render/SiteJarMojo.java +++ b/src/main/java/org/apache/maven/plugins/site/render/SiteJarMojo.java @@ -115,6 +115,16 @@ public class SiteJarMojo @Parameter private String[] archiveExcludes; + /** + * 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.9.0 + */ + @Parameter( defaultValue = "${project.build.outputTimestamp}" ) + private String outputTimestamp; + /** * @see org.apache.maven.plugin.Mojo#execute() */ @@ -179,14 +189,18 @@ private File createArchive( File siteDirectory, String jarFilename ) File siteJar = new File( jarOutputDirectory, jarFilename ); MavenArchiver archiver = new MavenArchiver(); + archiver.setCreatedBy( "Maven Site Plugin", "org.apache.maven.plugins", "maven-site-plugin" ); archiver.setArchiver( this.jarArchiver ); archiver.setOutputFile( siteJar ); + // configure for Reproducible Builds based on outputTimestamp value + archiver.configureReproducible( outputTimestamp ); + if ( !siteDirectory.isDirectory() ) { - getLog().warn( "JAR will be empty - no content was marked for inclusion !" ); + getLog().warn( "JAR will be empty - no content was marked for inclusion!" ); } else {