[MJLINK-75] create reproducible zip archive
diff --git a/pom.xml b/pom.xml
index 693342c..ad800ca 100644
--- a/pom.xml
+++ b/pom.xml
@@ -28,7 +28,7 @@
</parent>
<artifactId>maven-jlink-plugin</artifactId>
- <version>3.1.1-SNAPSHOT</version>
+ <version>3.2.0-SNAPSHOT</version>
<packaging>maven-plugin</packaging>
<name>Apache Maven JLink Plugin</name>
@@ -113,6 +113,11 @@
<version>3.4.2</version>
</dependency>
<dependency>
+ <groupId>org.apache.maven</groupId>
+ <artifactId>maven-archiver</artifactId>
+ <version>3.6.1</version>
+ </dependency>
+ <dependency>
<groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-archiver</artifactId>
<version>4.9.1</version>
diff --git a/src/main/java/org/apache/maven/plugins/jlink/JLinkMojo.java b/src/main/java/org/apache/maven/plugins/jlink/JLinkMojo.java
index c9b135f..fcb57c0 100644
--- a/src/main/java/org/apache/maven/plugins/jlink/JLinkMojo.java
+++ b/src/main/java/org/apache/maven/plugins/jlink/JLinkMojo.java
@@ -42,6 +42,7 @@
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
+import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -50,6 +51,7 @@
import java.util.Optional;
import org.apache.commons.io.FileUtils;
+import org.apache.maven.archiver.MavenArchiver;
import org.apache.maven.artifact.Artifact;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.MojoFailureException;
@@ -340,6 +342,16 @@
private String finalName;
/**
+ * 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;
+
+ /**
* Convenience interface for plugins to add or replace artifacts and resources on projects.
*/
@Component
@@ -510,6 +522,12 @@
throws MojoExecutionException {
zipArchiver.addDirectory(outputDirectoryImage);
+ // configure for Reproducible Builds based on outputTimestamp value
+ Date lastModified = new MavenArchiver().parseOutputTimestamp(outputTimestamp);
+ if (lastModified != null) {
+ zipArchiver.configureReproducible(lastModified);
+ }
+
File resultArchive = getArchiveFile(outputDirectory, finalName, getClassifier(), "zip");
zipArchiver.setDestFile(resultArchive);