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-remote-resources-plugin.git
The following commit(s) were added to refs/heads/master by this push:
new 33022e1 [MRRESOURCES-114] use reproducible
project.build.outputTimestamp
33022e1 is described below
commit 33022e15c1f6212443bd9d10367f07b666fb69b6
Author: Hervé Boutemy <[email protected]>
AuthorDate: Sat Jan 18 21:39:33 2020 +0100
[MRRESOURCES-114] use reproducible project.build.outputTimestamp
---
pom.xml | 5 +++++
.../resources/remote/ProcessRemoteResourcesMojo.java | 15 ++++++++++++++-
.../plugin/resources/remote/RemoteResourcesMojoTest.java | 2 +-
.../resources/unit/rrmojotest/process-plugin-config.xml | 1 +
4 files changed, 21 insertions(+), 2 deletions(-)
diff --git a/pom.xml b/pom.xml
index 7976702..9879260 100644
--- a/pom.xml
+++ b/pom.xml
@@ -115,6 +115,11 @@ under the License.
<!-- maven shared -->
<dependency>
+ <groupId>org.apache.maven</groupId>
+ <artifactId>maven-archiver</artifactId>
+ <version>3.5.0</version>
+ </dependency>
+ <dependency>
<groupId>org.apache.maven.shared</groupId>
<artifactId>maven-artifact-resolver</artifactId>
<version>1.0</version>
diff --git
a/src/main/java/org/apache/maven/plugin/resources/remote/ProcessRemoteResourcesMojo.java
b/src/main/java/org/apache/maven/plugin/resources/remote/ProcessRemoteResourcesMojo.java
index d64fe20..b7b9718 100644
---
a/src/main/java/org/apache/maven/plugin/resources/remote/ProcessRemoteResourcesMojo.java
+++
b/src/main/java/org/apache/maven/plugin/resources/remote/ProcessRemoteResourcesMojo.java
@@ -56,6 +56,7 @@ import java.util.TreeMap;
import org.apache.commons.io.output.DeferredFileOutputStream;
import org.apache.maven.ProjectDependenciesResolver;
+import org.apache.maven.archiver.MavenArchiver;
import org.apache.maven.artifact.Artifact;
import org.apache.maven.artifact.factory.ArtifactFactory;
import org.apache.maven.artifact.repository.ArtifactRepository;
@@ -428,6 +429,14 @@ public class ProcessRemoteResourcesMojo
protected boolean excludeTransitive;
/**
+ * 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>).
+ */
+ @Parameter( defaultValue = "${project.build.outputTimestamp}" )
+ private String outputTimestamp;
+
+ /**
*/
@Component( hint = "default" )
protected ProjectDependenciesResolver dependencyResolver;
@@ -1040,8 +1049,12 @@ public class ProcessRemoteResourcesMojo
context.put( KEY_PROJECTS_ORGS, null );
// the following properties are cheap to calculate, so we provide them
eagerly
+ // Reproducible Builds: try to use reproducible output timestamp
+ MavenArchiver archiver = new MavenArchiver();
+ Date outputDate = archiver.parseOutputTimestamp( outputTimestamp );
+
String inceptionYear = project.getInceptionYear();
- String year = new SimpleDateFormat( "yyyy" ).format( new Date() );
+ String year = new SimpleDateFormat( "yyyy" ).format( ( outputDate ==
null ) ? new Date() : outputDate );
if ( StringUtils.isEmpty( inceptionYear ) )
{
diff --git
a/src/test/java/org/apache/maven/plugin/resources/remote/RemoteResourcesMojoTest.java
b/src/test/java/org/apache/maven/plugin/resources/remote/RemoteResourcesMojoTest.java
index 16842b0..24c928f 100644
---
a/src/test/java/org/apache/maven/plugin/resources/remote/RemoteResourcesMojoTest.java
+++
b/src/test/java/org/apache/maven/plugin/resources/remote/RemoteResourcesMojoTest.java
@@ -327,7 +327,7 @@ public class RemoteResourcesMojoTest
String data = FileUtils.fileRead( file );
assertTrue( data.contains( "project.name: Test Project
default-filterbundles" ) );
- assertTrue( data.contains( "projectTimespan: 2007-" ) );
+ assertTrue( data.contains( "projectTimespan: 2007-2019" ) );
assertTrue( data.contains( "projects: [" ) );
assertTrue( data.contains( "projectsSortedByOrganization: {" ) );
}
diff --git a/src/test/resources/unit/rrmojotest/process-plugin-config.xml
b/src/test/resources/unit/rrmojotest/process-plugin-config.xml
index 8d3ab14..0f97b40 100644
--- a/src/test/resources/unit/rrmojotest/process-plugin-config.xml
+++ b/src/test/resources/unit/rrmojotest/process-plugin-config.xml
@@ -26,6 +26,7 @@ under the License.
<configuration>
<localRepository>${localRepository}</localRepository>
<encoding>UTF-8</encoding>
+ <outputTimestamp>2019-12-31T12:00:00Z</outputTimestamp>
</configuration>
</plugin>
</plugins>