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-archiver.git
The following commit(s) were added to refs/heads/master by this push: new 1c2a2cc improve Reproducible Builds javadoc after #281 1c2a2cc is described below commit 1c2a2cc3a5f5af6fe216376c0b60797b62d0bd00 Author: Hervé Boutemy <hbout...@apache.org> AuthorDate: Thu Jul 24 15:11:43 2025 +0200 improve Reproducible Builds javadoc after #281 --- .../org/apache/maven/shared/archiver/MavenArchiver.java | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/main/java/org/apache/maven/shared/archiver/MavenArchiver.java b/src/main/java/org/apache/maven/shared/archiver/MavenArchiver.java index 0e5da57..550831d 100644 --- a/src/main/java/org/apache/maven/shared/archiver/MavenArchiver.java +++ b/src/main/java/org/apache/maven/shared/archiver/MavenArchiver.java @@ -669,6 +669,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) @@ -677,16 +680,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; } } @@ -720,7 +724,6 @@ public class MavenArchiver { } private static boolean isNumeric(String str) { - if (str.isEmpty()) { return false; }