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 2025/07/24 13:11:54 UTC

(maven-archiver) branch rb-doc created (now 4226956)

This is an automated email from the ASF dual-hosted git repository.

hboutemy pushed a change to branch rb-doc
in repository https://gitbox.apache.org/repos/asf/maven-archiver.git


      at 4226956  improve Reproducible Builds javadoc after #281

This branch includes the following new commits:

     new 4226956  improve Reproducible Builds javadoc after #281

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



(maven-archiver) 01/01: improve Reproducible Builds javadoc after #281

Posted by hb...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

hboutemy pushed a commit to branch rb-doc
in repository https://gitbox.apache.org/repos/asf/maven-archiver.git

commit 4226956116576957efb9c35ea79aa36b498a2c2d
Author: Hervé Boutemy <hb...@apache.org>
AuthorDate: Thu Jul 24 15:11:43 2025 +0200

    improve Reproducible Builds javadoc after #281
---
 src/main/java/org/apache/maven/archiver/MavenArchiver.java | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/src/main/java/org/apache/maven/archiver/MavenArchiver.java b/src/main/java/org/apache/maven/archiver/MavenArchiver.java
index 9330df4..be0b6a5 100644
--- a/src/main/java/org/apache/maven/archiver/MavenArchiver.java
+++ b/src/main/java/org/apache/maven/archiver/MavenArchiver.java
@@ -66,7 +66,6 @@ import static org.apache.maven.archiver.ManifestConfiguration.CLASSPATH_LAYOUT_T
  *
  * @author <a href="evenisse@apache.org">Emmanuel Venisse</a>
  * @author kama
- * @version $Id: $Id
  */
 public class MavenArchiver {
 
@@ -745,6 +744,9 @@ public class MavenArchiver {
      * <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,16 +755,17 @@ public class MavenArchiver {
      *             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) {
-        final String sourceDateEpoch = System.getenv("SOURCE_DATE_EPOCH");
         // 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))) {
-            if (sourceDateEpoch == null) {
+            // Reproducible Builds not configured or disabled => fallback to SOURCE_DATE_EPOCH env
+            outputTimestamp = System.getenv("SOURCE_DATE_EPOCH");
+            if (outputTimestamp == null) {
                 return Optional.empty();
-            } else {
-                outputTimestamp = sourceDateEpoch;
             }
         }
 
@@ -796,7 +799,6 @@ public class MavenArchiver {
     }
 
     private static boolean isNumeric(String str) {
-
         if (str.isEmpty()) {
             return false;
         }