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 2019/08/21 20:41:46 UTC
[maven-source-plugin] branch MSOURCES-120 updated: MSOURCES-120 PoC
reproducible source jar implementation
This is an automated email from the ASF dual-hosted git repository.
hboutemy pushed a commit to branch MSOURCES-120
in repository https://gitbox.apache.org/repos/asf/maven-source-plugin.git
The following commit(s) were added to refs/heads/MSOURCES-120 by this push:
new 042115c MSOURCES-120 PoC reproducible source jar implementation
042115c is described below
commit 042115c1b718e1a47eb9951e164926f710d44e21
Author: Hervé Boutemy <hb...@apache.org>
AuthorDate: Wed Aug 21 22:41:42 2019 +0200
MSOURCES-120 PoC reproducible source jar implementation
Still need to define how really the source-date-epoch value will be
configured, and with which value
But at least permits to test the result on multiple configurations, to
see if there are other unexpected not reproducible aspects
---
pom.xml | 7 ++++++-
src/it/reproducible/pom.xml | 3 +++
src/it/reproducible/verify.groovy | 2 +-
.../apache/maven/plugins/source/AbstractSourceJarMojo.java | 14 ++++++++++++++
4 files changed, 24 insertions(+), 2 deletions(-)
diff --git a/pom.xml b/pom.xml
index ebe3967..d279964 100644
--- a/pom.xml
+++ b/pom.xml
@@ -115,7 +115,12 @@ under the License.
<dependency>
<groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-archiver</artifactId>
- <version>4.1.0</version>
+ <version>4.2.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.commons</groupId>
+ <artifactId>commons-compress</artifactId>
+ <version>1.19-SNAPSHOT</version>
</dependency>
<dependency>
diff --git a/src/it/reproducible/pom.xml b/src/it/reproducible/pom.xml
index 8acbab0..13a6af9 100644
--- a/src/it/reproducible/pom.xml
+++ b/src/it/reproducible/pom.xml
@@ -39,6 +39,9 @@
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<version>@project.version@</version>
+ <configuration>
+ <source-date-epoch>1566419331</source-date-epoch>
+ </configuration>
</plugin>
<plugin>
<artifactId>maven-deploy-plugin</artifactId>
diff --git a/src/it/reproducible/verify.groovy b/src/it/reproducible/verify.groovy
index 76d040f..f211d59 100644
--- a/src/it/reproducible/verify.groovy
+++ b/src/it/reproducible/verify.groovy
@@ -30,4 +30,4 @@ String sha1 = sha1File.text
println( "reproducible-1.0-sources.jar sha1 = $sha1" )
-assert sha1 == 'reproducible sha1 to be defined'
+assert sha1 == '77f410a2606f3e57e6195fb69164da59faa7af31'
diff --git a/src/main/java/org/apache/maven/plugins/source/AbstractSourceJarMojo.java b/src/main/java/org/apache/maven/plugins/source/AbstractSourceJarMojo.java
index 844c1fc..976195e 100644
--- a/src/main/java/org/apache/maven/plugins/source/AbstractSourceJarMojo.java
+++ b/src/main/java/org/apache/maven/plugins/source/AbstractSourceJarMojo.java
@@ -23,6 +23,7 @@ import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
+import java.util.Date;
import java.util.List;
import org.apache.maven.archiver.MavenArchiveConfiguration;
@@ -196,6 +197,14 @@ public abstract class AbstractSourceJarMojo
@Parameter( defaultValue = "${session}", readonly = true, required = true )
private MavenSession session;
+ /**
+ * Value like SOURCE_DATE_EPOCH as <a href="https://reproducible-builds.org/specs/source-date-epoch/">defined in
+ * Reproducible Builds</a>: a UNIX timestamp, defined as the number of seconds, excluding leap seconds, since 01 Jan
+ * 1970 00:00:00 UTC.
+ */
+ @Parameter( name = "source-date-epoch" )
+ private int sourceDateEpoch;
+
// ----------------------------------------------------------------------
// Public methods
// ----------------------------------------------------------------------
@@ -270,6 +279,11 @@ public abstract class AbstractSourceJarMojo
}
MavenArchiver archiver = createArchiver();
+
+ if ( sourceDateEpoch != 0 )
+ {
+ archiver.getArchiver().setLastModifiedDate( new Date( 1000L * sourceDateEpoch ) );
+ }
for ( MavenProject pItem : theProjects )
{