This closes #186 pull request at github/apache/ant repo.master
| @@ -309,6 +309,7 @@ Miha | |||||
| Mike Davis | Mike Davis | ||||
| Mike Roberts | Mike Roberts | ||||
| Mike Williams | Mike Williams | ||||
| Mikolaj Izdebski | |||||
| Miroslav Zaťko | Miroslav Zaťko | ||||
| Mounir El Hajj | Mounir El Hajj | ||||
| Nathan Beyer | Nathan Beyer | ||||
| @@ -25,6 +25,10 @@ Fixed bugs: | |||||
| timestamps of files transferred recursively from a server. | timestamps of files transferred recursively from a server. | ||||
| Bugzilla Report 66001 | Bugzilla Report 66001 | ||||
| * tstamp task would in certain cases parse the SOURCE_DATE_EPOCH environment variable | |||||
| value to an incorrect date. This has now been fixed. | |||||
| Github Pull Request #186 | |||||
| Other changes: | Other changes: | ||||
| -------------- | -------------- | ||||
| @@ -1280,6 +1280,10 @@ | |||||
| <first>Mike</first> | <first>Mike</first> | ||||
| <last>Williams</last> | <last>Williams</last> | ||||
| </name> | </name> | ||||
| <name> | |||||
| <first>Mikolaj</first> | |||||
| <last>Izdebski</last> | |||||
| </name> | |||||
| <name> | <name> | ||||
| <first>Miroslav</first> | <first>Miroslav</first> | ||||
| <last>Zaťko</last> | <last>Zaťko</last> | ||||
| @@ -82,7 +82,7 @@ public class Tstamp extends Task { | |||||
| try { | try { | ||||
| if (epoch != null) { | if (epoch != null) { | ||||
| // Value of SOURCE_DATE_EPOCH will be an integer, representing seconds. | // Value of SOURCE_DATE_EPOCH will be an integer, representing seconds. | ||||
| d = new Date(Integer.parseInt(epoch) * 1000); | |||||
| d = new Date(Long.parseLong(epoch) * 1000L); | |||||
| log("Honouring environment variable " + ENV_SOURCE_DATE_EPOCH + " which has been set to " + epoch); | log("Honouring environment variable " + ENV_SOURCE_DATE_EPOCH + " which has been set to " + epoch); | ||||
| } | } | ||||
| } catch(NumberFormatException e) { | } catch(NumberFormatException e) { | ||||
| @@ -75,4 +75,35 @@ public class IsEpochIn1969Here implements Condition { | |||||
| <!-- 'iso' overrides 'simple' --> | <!-- 'iso' overrides 'simple' --> | ||||
| <au:assertPropertyEquals name="DSTAMP" value="19720417"/> | <au:assertPropertyEquals name="DSTAMP" value="19720417"/> | ||||
| </target> | </target> | ||||
| <target name="testSourceDateEpoch"> | |||||
| <mkdir dir="${input}"/> | |||||
| <mkdir dir="${output}"/> | |||||
| <echo file="${input}/TstampAntunitTest.java"><![CDATA[ | |||||
| import org.apache.tools.ant.*; | |||||
| import org.apache.tools.ant.taskdefs.*; | |||||
| public class TstampAntunitTest { | |||||
| public static void main(String[] args) { | |||||
| Task task = new Tstamp(); | |||||
| task.setProject(new Project()); | |||||
| task.execute(); | |||||
| String today = task.getProject().getProperty("TODAY"); | |||||
| System.out.println("TODAY is " + today); | |||||
| } | |||||
| } | |||||
| ]]></echo> | |||||
| <javac srcdir="${input}" destdir="${output}"/> | |||||
| <local name="testout"/> | |||||
| <java classname="TstampAntunitTest" | |||||
| failonerror="true" | |||||
| outputproperty="testout" | |||||
| fork="true"> | |||||
| <classpath> | |||||
| <pathelement location="${output}"/> | |||||
| <pathelement path="${java.class.path}"/> | |||||
| </classpath> | |||||
| <env key="SOURCE_DATE_EPOCH" value="1650585600"/> | |||||
| </java> | |||||
| <au:assertEquals expected="TODAY is April 22 2022" actual="${testout}"/> | |||||
| </target> | |||||
| </project> | </project> | ||||