File reproducible-from-environment.patch of Package maven-archiver
--- maven-archiver-3.6.3/pom.xml 2025-07-25 08:59:38.427807182 +0200
+++ maven-archiver-3.6.3/pom.xml 2025-07-25 08:59:51.766807935 +0200
@@ -115,4 +115,22 @@
<scope>test</scope>
</dependency>
</dependencies>
+
+ <build>
+ <pluginManagement>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <configuration>
+ <redirectTestOutputToFile>true</redirectTestOutputToFile>
+ <excludedEnvironmentVariables>
+ <excludedEnvironmentVariable>SOURCE_DATE_EPOCH</excludedEnvironmentVariable>
+ </excludedEnvironmentVariables>
+ </configuration>
+ </plugin>
+ </plugins>
+ </pluginManagement>
+ </build>
+
</project>
--- maven-archiver-3.6.3/src/main/java/org/apache/maven/archiver/MavenArchiver.java 2025-07-25 08:59:38.426221268 +0200
+++ maven-archiver-3.6.3/src/main/java/org/apache/maven/archiver/MavenArchiver.java 2025-07-25 09:00:55.991543025 +0200
@@ -66,7 +66,6 @@
*
* @author <a href="evenisse@apache.org">Emmanuel Venisse</a>
* @author kama
- * @version $Id: $Id
*/
public class MavenArchiver {
@@ -745,6 +744,9 @@
* <p>Either as {@link java.time.format.DateTimeFormatter#ISO_OFFSET_DATE_TIME} or as a number representing seconds
* since the epoch (like <a href="https://reproducible-builds.org/docs/source-date-epoch/">SOURCE_DATE_EPOCH</a>).
*
+ * <p>Since 3.6.4, if not configured or disabled, the {@code SOURCE_DATE_EPOCH} environment variable is used as
+ * a fallback value, to ease forcing Reproducible Build externally when the build has not enabled it natively in POM.
+ *
* @param outputTimestamp the value of {@code ${project.build.outputTimestamp}} (may be {@code null})
* @return the parsed timestamp as an {@code Optional<Instant>}, {@code empty} if input is {@code null} or input
* contains only 1 character (not a number)
@@ -753,12 +755,19 @@
* the valid range 1980-01-01T00:00:02Z to 2099-12-31T23:59:59Z as defined by
* <a href="https://pkwaredownloads.blob.core.windows.net/pem/APPNOTE.txt">ZIP application note</a>,
* section 4.4.6.
+ * @see <a href="https://cwiki.apache.org/confluence/pages/viewpage.action?pageId=74682318">Maven Wiki "Reproducible/Verifiable
+ * Builds"</a>
*/
public static Optional<Instant> parseBuildOutputTimestamp(String outputTimestamp) {
- // Fail-fast on nulls
+ // Fail fast on null and no timestamp configured (1 character configuration is useful to override
+ // a full value during pom inheritance)
+ if (outputTimestamp == null || (outputTimestamp.length() < 2 && !isNumeric(outputTimestamp))) {
+ // Reproducible Builds not configured or disabled => fallback to SOURCE_DATE_EPOCH env
+ outputTimestamp = System.getenv("SOURCE_DATE_EPOCH");
if (outputTimestamp == null) {
return Optional.empty();
}
+ }
// Number representing seconds since the epoch
if (isNumeric(outputTimestamp)) {
@@ -771,12 +780,6 @@
return Optional.of(date);
}
- // no timestamp configured (1 character configuration is useful to override a full value during pom
- // inheritance)
- if (outputTimestamp.length() < 2) {
- return Optional.empty();
- }
-
try {
// Parse the date in UTC such as '2011-12-03T10:15:30Z' or with an offset '2019-10-05T20:37:42+06:00'.
final Instant date = OffsetDateTime.parse(outputTimestamp)