From d45eca907803c5132388d42d9fc0023b0fa757cc Mon Sep 17 00:00:00 2001 From: "Bernhard M. Wiedemann" Date: Mon, 8 May 2017 08:55:11 +0200 Subject: [PATCH] allow to override timestamps with SOURCE_DATE_EPOCH to allow for reproducible builds of software built with ant such as ant and jcodings See https://reproducible-builds.org/ for why this is good and https://reproducible-builds.org/specs/source-date-epoch/ for the definition of this variable. --- src/main/org/apache/tools/ant/taskdefs/Tstamp.java | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/main/org/apache/tools/ant/taskdefs/Tstamp.java b/src/main/org/apache/tools/ant/taskdefs/Tstamp.java index 0610c399c..de885e146 100644 --- a/src/main/org/apache/tools/ant/taskdefs/Tstamp.java +++ b/src/main/org/apache/tools/ant/taskdefs/Tstamp.java @@ -69,7 +69,14 @@ public class Tstamp extends Task { @Override public void execute() throws BuildException { try { - Date d = new Date(); + Date d; + String sde = System.getenv("SOURCE_DATE_EPOCH"); + if (sde != null) { + long x = Long.parseLong(sde); + d = new Date(x*1000); + } else { + d = new Date(); + } customFormats.forEach(cts -> cts.execute(getProject(), d, getLocation())); -- 2.12.0