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-site-plugin.git
The following commit(s) were added to refs/heads/master by this push: new 19be00a MSITE-851 make output jars reproducible like m-source-p 19be00a is described below commit 19be00a9bf2a410abb7132487dc24055060b2c70 Author: Hervé Boutemy <hbout...@apache.org> AuthorDate: Sat Nov 2 18:11:54 2019 +0100 MSITE-851 make output jars reproducible like m-source-p --- pom.xml | 8 ++++---- src/it/projects/site-jar/pom.xml | 1 + src/it/projects/site-jar/verify.bsh | 5 +++++ .../apache/maven/plugins/site/render/SiteJarMojo.java | 16 +++++++++++++++- 4 files changed, 25 insertions(+), 5 deletions(-) diff --git a/pom.xml b/pom.xml index 556df16..67efc68 100644 --- a/pom.xml +++ b/pom.xml @@ -30,7 +30,7 @@ under the License. </parent> <artifactId>maven-site-plugin</artifactId> - <version>3.8.3-SNAPSHOT</version> + <version>3.9.0-SNAPSHOT</version> <packaging>maven-plugin</packaging> <name>Apache Maven Site Plugin</name> @@ -283,7 +283,7 @@ under the License. <dependency> <groupId>org.apache.maven</groupId> <artifactId>maven-archiver</artifactId> - <version>3.1.1</version> + <version>3.5.0</version> </dependency> <!-- dependencies to annotations --> @@ -302,7 +302,7 @@ under the License. <dependency> <groupId>org.codehaus.plexus</groupId> <artifactId>plexus-archiver</artifactId> - <version>3.4</version> + <version>4.2.1</version> </dependency> <dependency> @@ -319,7 +319,7 @@ under the License. <dependency> <groupId>org.codehaus.plexus</groupId> <artifactId>plexus-utils</artifactId> - <version>3.0.24</version> + <version>3.3.0</version> </dependency> <dependency> diff --git a/src/it/projects/site-jar/pom.xml b/src/it/projects/site-jar/pom.xml index dcd739f..d76a8ea 100644 --- a/src/it/projects/site-jar/pom.xml +++ b/src/it/projects/site-jar/pom.xml @@ -34,6 +34,7 @@ under the License. <properties> <currentVersion>2.0.7</currentVersion> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> + <project.build.outputTimestamp>2019-11-02T17:48:12Z</project.build.outputTimestamp> </properties> <distributionManagement> diff --git a/src/it/projects/site-jar/verify.bsh b/src/it/projects/site-jar/verify.bsh index d28a242..c512531 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 211eb6a..26be6d4 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 @@ -116,6 +116,16 @@ public class SiteJarMojo private String[] archiveExcludes; /** + * 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.9.0 + */ + @Parameter( defaultValue = "${project.build.outputTimestamp}" ) + private String outputTimestamp; + + /** * @see org.apache.maven.plugin.Mojo#execute() */ public void execute() @@ -179,14 +189,18 @@ public class SiteJarMojo 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 {