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

asf-gitbox-commits pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/ant.git


The following commit(s) were added to refs/heads/master by this push:
     new 57b9fab79 Project#getNow -> Project#getBuildDate
57b9fab79 is described below

commit 57b9fab79573b69d076c9296c72ea1aa53062cd1
Author: Stefan Bodewig <[email protected]>
AuthorDate: Fri Aug 14 06:45:22 2026 +0200

    Project#getNow -> Project#getBuildDate
---
 WHATSNEW                                           |  6 ++--
 src/main/org/apache/tools/ant/Project.java         |  6 ++--
 .../tools/ant/taskdefs/optional/PropertyFile.java  |  2 +-
 src/tests/antunit/core/project-test.xml            | 42 +++++++++++-----------
 4 files changed, 28 insertions(+), 28 deletions(-)

diff --git a/WHATSNEW b/WHATSNEW
index 79f2c221d..25a4ef031 100644
--- a/WHATSNEW
+++ b/WHATSNEW
@@ -22,11 +22,11 @@ Other changes:
    Based on a patch used by the Debian Ant package maintainers.
    Part of Bugzilla Report 61269
 
- * a new method getNow in Project can now be used to calculate a
-   notion of "now" that consults the SOURCE_DATE_EPOCH environment
+ * a new method getBuildDate in Project can now be used to calculate a
+   notion of a "uild date" that consults the SOURCE_DATE_EPOCH environment
    variable as well as the magic ant.tstamp.now and ant.tstamp.now.iso
    properties in this order which you can use if you want to obtain a
-   reproducible timestamp in task you write yourself.
+   reproducible timestamp in tasks you write yourself.
 
  * The "record" task now has a new "relativeToBaseDir" attribute,
    which can be set to "yes" or "no", to control where the
diff --git a/src/main/org/apache/tools/ant/Project.java 
b/src/main/org/apache/tools/ant/Project.java
index 274b94de7..d12660c87 100644
--- a/src/main/org/apache/tools/ant/Project.java
+++ b/src/main/org/apache/tools/ant/Project.java
@@ -2493,15 +2493,15 @@ public class Project implements ResourceFactory {
     /**
      * Consults {@linkplain #ENV_SOURCE_DATE_EPOCH SOURCE_DATE_EPOCH} 
environment variable and
      * the magic properties {@link MagicNames#TSTAMP_NOW_ISO} and {@link 
MagicNames#TSTAMP_NOW}
-     * for predefined values of "now" and falls back to {@code new Date()} if 
neither is set.
+     * for predefined values of the build date and falls back to {@code new 
Date()} if neither is set.
      *
      * <p>{@code SOURCE_DATE_EPOCH} takes precedence over {@link 
MagicNames#TSTAMP_NOW_ISO} which
      * in turn takes precedence over {@link MagicNames#TSTAMP_NOW}.</p>
      *
-     * @return "now" as explained above
+     * @return "build date" as explained above
      * @since Ant 1.10.18
      */
-    public Date getNow() {
+    public Date getBuildDate() {
         final String epoch = System.getenv(DateUtils.ENV_SOURCE_DATE_EPOCH);
         if (epoch != null) {
             // Value of SOURCE_DATE_EPOCH will be an integer, representing 
seconds.
diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/PropertyFile.java 
b/src/main/org/apache/tools/ant/taskdefs/optional/PropertyFile.java
index a6cfdadce..ba517bed5 100644
--- a/src/main/org/apache/tools/ant/taskdefs/optional/PropertyFile.java
+++ b/src/main/org/apache/tools/ant/taskdefs/optional/PropertyFile.java
@@ -194,7 +194,7 @@ public class PropertyFile extends Task {
         } else {
             LayoutPreservingProperties p = new LayoutPreservingProperties();
             Calendar c = Calendar.getInstance();
-            c.setTime(getProject().getNow());
+            c.setTime(getProject().getBuildDate());
             TimeZone tz = System.getenv(DateUtils.ENV_SOURCE_DATE_EPOCH) != 
null
                 ? TimeZone.getTimeZone("UTC") : null;
             p.setDateComment(c, tz);
diff --git a/src/tests/antunit/core/project-test.xml 
b/src/tests/antunit/core/project-test.xml
index 09c663fc3..01c41289c 100644
--- a/src/tests/antunit/core/project-test.xml
+++ b/src/tests/antunit/core/project-test.xml
@@ -18,15 +18,15 @@
 <project default="antunit" name="project-test" 
xmlns:au="antlib:org.apache.ant.antunit">
   <import file="../antunit-base.xml" />
 
-  <target name="-createNowPrinter">
+  <target name="-createBuildDatePrinter">
     <mkdir dir="${input}"/>
     <mkdir dir="${output}"/>
-    <echo file="${input}/NowPrinter.java"><![CDATA[
+    <echo file="${input}/BuildDatePrinter.java"><![CDATA[
       import org.apache.tools.ant.BuildException;
       import org.apache.tools.ant.Project;
       import java.text.SimpleDateFormat;
       import java.util.*;
-      public class NowPrinter {
+      public class BuildDatePrinter {
         public static void main(String[] args) {
           Project p = new Project();
           int argsLen = args.length;
@@ -36,19 +36,19 @@
           for (int i = 0; i < argsLen; i += 2) {
             p.setProperty(args[i], args[i + 1]);
           }
-          Date now = p.getNow();
+          Date buildDate = p.getBuildDate();
           SimpleDateFormat format = new 
SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss");
           format.setTimeZone(TimeZone.getTimeZone("UTC"));
-          System.out.println("NOW is " + format.format(now));
+          System.out.println("BUILDDATE is " + format.format(buildDate));
         }
       }
     ]]></echo>
     <javac srcdir="${input}" destdir="${output}"/>
   </target>
 
-  <target name="testGetNowMagicProperty" depends="-createNowPrinter">
+  <target name="testGetBuildDateMagicProperty" 
depends="-createBuildDatePrinter">
     <local name="testout"/>
-    <java classname="NowPrinter"
+    <java classname="BuildDatePrinter"
           failonerror="true"
           outputproperty="testout"
           fork="true">
@@ -59,12 +59,12 @@
       <arg value="ant.tstamp.now"/>
       <arg value="86400"/>
     </java>
-    <au:assertPropertyContains name="testout" value="NOW is 
1970-01-02T00:00:00"/>
+    <au:assertPropertyContains name="testout" value="BUILDDATE is 
1970-01-02T00:00:00"/>
   </target>
 
-  <target name="testGetNowMagicPropertyIso" depends="-createNowPrinter">
+  <target name="testGetBuildDateMagicPropertyIso" 
depends="-createBuildDatePrinter">
     <local name="testout"/>
-    <java classname="NowPrinter"
+    <java classname="BuildDatePrinter"
           failonerror="true"
           outputproperty="testout"
           fork="true">
@@ -75,12 +75,12 @@
       <arg value="ant.tstamp.now.iso"/>
       <arg value="1972-04-17T08:07:00Z"/>
     </java>
-    <au:assertPropertyContains name="testout" value="NOW is 
1972-04-17T08:07:00"/>
+    <au:assertPropertyContains name="testout" value="BUILDDATE is 
1972-04-17T08:07:00"/>
   </target>
 
-  <target name="testGetNowMagicPropertyBoth" depends="-createNowPrinter">
+  <target name="testGetBuildDateMagicPropertyBoth" 
depends="-createBuildDatePrinter">
     <local name="testout"/>
-    <java classname="NowPrinter"
+    <java classname="BuildDatePrinter"
           failonerror="true"
           outputproperty="testout"
           fork="true">
@@ -93,12 +93,12 @@
       <arg value="ant.tstamp.now.iso"/>
       <arg value="1972-04-17T08:07:00Z"/>
     </java>
-    <au:assertPropertyContains name="testout" value="NOW is 
1972-04-17T08:07:00"/>
+    <au:assertPropertyContains name="testout" value="BUILDDATE is 
1972-04-17T08:07:00"/>
   </target>
 
-  <target name="testGetNowSourceDateEpoch" depends="-createNowPrinter">
+  <target name="testGetBuildDateSourceDateEpoch" 
depends="-createBuildDatePrinter">
     <local name="testout"/>
-    <java classname="NowPrinter"
+    <java classname="BuildDatePrinter"
           failonerror="true"
           outputproperty="testout"
           fork="true">
@@ -112,18 +112,18 @@
       <arg value="1972-04-17T08:07:00Z"/>
       <env key="SOURCE_DATE_EPOCH" value="1650585600"/>
     </java>
-    <au:assertPropertyContains name="testout" value="NOW is 
2022-04-22T00:00:00"/>
+    <au:assertPropertyContains name="testout" value="BUILDDATE is 
2022-04-22T00:00:00"/>
   </target>
 
-  <target name="testGetNowRealNow" depends="-createNowPrinter">
+  <target name="testGetBuildDateRealNow" depends="-createBuildDatePrinter">
     <local name="dstamp"/>
     <local name="testout"/>
     <!-- ignoring the time part and hoping the clock doesn't pass
-         midnight between running tstamp and NowPrinter -->
+         midnight between running tstamp and BuildDatePrinter -->
     <tstamp>
       <format pattern="yyyy-MM-dd" property="dstamp" timezone="UTC"/>
     </tstamp>
-    <java classname="NowPrinter"
+    <java classname="BuildDatePrinter"
           failonerror="true"
           outputproperty="testout"
           fork="true">
@@ -132,6 +132,6 @@
         <pathelement path="${java.class.path}"/>
       </classpath>
     </java>
-    <au:assertPropertyContains name="testout" value="NOW is ${dstamp}T"/>
+    <au:assertPropertyContains name="testout" value="BUILDDATE is ${dstamp}T"/>
   </target>
 </project>

Reply via email to