You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by hb...@apache.org on 2024/01/23 03:40:22 UTC
(maven-jlink-plugin) 01/01: [MJLINK-75] create reproducible zip archive
This is an automated email from the ASF dual-hosted git repository.
hboutemy pushed a commit to branch MJLINK-75
in repository https://gitbox.apache.org/repos/asf/maven-jlink-plugin.git
commit 2b6b5cc54860f15cfe1b0ce2bcd77771951e9286
Author: Hervé Boutemy <hb...@apache.org>
AuthorDate: Tue Jan 23 04:40:06 2024 +0100
[MJLINK-75] create reproducible zip archive
---
pom.xml | 7 ++++++-
.../java/org/apache/maven/plugins/jlink/JLinkMojo.java | 18 ++++++++++++++++++
2 files changed, 24 insertions(+), 1 deletion(-)
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>
@@ -112,6 +112,11 @@
<artifactId>maven-shared-utils</artifactId>
<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>
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.io.IOException;
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.NoSuchElementException;
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;
@@ -339,6 +341,16 @@ public class JLinkMojo extends AbstractJLinkMojo {
@Parameter(defaultValue = "${project.build.finalName}", readonly = true)
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.
*/
@@ -510,6 +522,12 @@ public class JLinkMojo extends AbstractJLinkMojo {
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);