@@ -221,6 +221,7 @@ Joseph Walton | |||||
Josh Lucas | Josh Lucas | ||||
Juerg Wanner | Juerg Wanner | ||||
Julian Simpson | Julian Simpson | ||||
Julien Lepiller | |||||
Justin Vallon | Justin Vallon | ||||
Justyna Horwat | Justyna Horwat | ||||
Karl Jansen | Karl Jansen | ||||
@@ -20,6 +20,10 @@ Other changes: | |||||
* The runant.py script should now work with Python 3. | * The runant.py script should now work with Python 3. | ||||
Github Pull Request #96 | Github Pull Request #96 | ||||
* tstamp task now honors SOURCE_DATE_EPOCH environment variable for | |||||
reproducible builds (https://reproducible-builds.org/specs/source-date-epoch/#idm55) | |||||
Bugzilla Report 62617 | |||||
Changes from Ant 1.10.6 TO Ant 1.10.7 | Changes from Ant 1.10.6 TO Ant 1.10.7 | ||||
===================================== | ===================================== | ||||
@@ -923,6 +923,10 @@ | |||||
<first>Julian</first> | <first>Julian</first> | ||||
<last>Simpson</last> | <last>Simpson</last> | ||||
</name> | </name> | ||||
<name> | |||||
<first>Julien</first> | |||||
<last>Lepiller</last> | |||||
</name> | |||||
<name> | <name> | ||||
<first>Justin</first> | <first>Justin</first> | ||||
<last>Vallon</last> | <last>Vallon</last> | ||||
@@ -44,6 +44,13 @@ you could also specify that value in ISO-8601 format (<code>1972-04-17T08:07:00Z | |||||
specify a value in an invalid format an INFO message will be logged and the value will be | specify a value in an invalid format an INFO message will be logged and the value will be | ||||
ignored.</p> | ignored.</p> | ||||
<p> | |||||
<em>Since Ant 1.10.8</em> the <code>SOURCE_DATE_EPOCH</code> environment variable value (if set) | |||||
will be honoured for <a href="https://reproducible-builds.org/specs/source-date-epoch/#idm55">reproducible builds</a>. | |||||
Ant will log a DEBUG message if an invalid value (value that cannot be parsed to an integer), is specified | |||||
for that environment variable and will instead use the "current" date. | |||||
</p> | |||||
<h3>Parameters</h3> | <h3>Parameters</h3> | ||||
<table class="attr"> | <table class="attr"> | ||||
<tr> | <tr> | ||||
@@ -50,6 +50,8 @@ import org.apache.tools.ant.types.EnumeratedAttribute; | |||||
*/ | */ | ||||
public class Tstamp extends Task { | public class Tstamp extends Task { | ||||
private static final String ENV_SOURCE_DATE_EPOCH = "SOURCE_DATE_EPOCH"; | |||||
private List<CustomFormat> customFormats = new Vector<>(); | private List<CustomFormat> customFormats = new Vector<>(); | ||||
private String prefix = ""; | private String prefix = ""; | ||||
@@ -75,8 +77,21 @@ public class Tstamp extends Task { | |||||
public void execute() throws BuildException { | public void execute() throws BuildException { | ||||
try { | try { | ||||
Date d = getNow(); | Date d = getNow(); | ||||
customFormats.forEach(cts -> cts.execute(getProject(), d, getLocation())); | |||||
// Honour reproducible builds https://reproducible-builds.org/specs/source-date-epoch/#idm55 | |||||
final String epoch = System.getenv(ENV_SOURCE_DATE_EPOCH); | |||||
try { | |||||
if (epoch != null) { | |||||
// Value of SOURCE_DATE_EPOCH will be an integer, representing seconds. | |||||
d = new Date(Integer.parseInt(epoch) * 1000); | |||||
} | |||||
log("Honouring environment variable " + ENV_SOURCE_DATE_EPOCH + " which has been set to " + epoch); | |||||
} catch(NumberFormatException e) { | |||||
// ignore | |||||
log("Ignoring invalid value '" + epoch + "' for " + ENV_SOURCE_DATE_EPOCH | |||||
+ " environment variable", Project.MSG_DEBUG); | |||||
} | |||||
final Date date = d; | |||||
customFormats.forEach(cts -> cts.execute(getProject(), date, getLocation())); | |||||
SimpleDateFormat dstamp = new SimpleDateFormat("yyyyMMdd"); | SimpleDateFormat dstamp = new SimpleDateFormat("yyyyMMdd"); | ||||
setProperty("DSTAMP", dstamp.format(d)); | setProperty("DSTAMP", dstamp.format(d)); | ||||