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 d69e95655 use a setter instead of a constructor
d69e95655 is described below

commit d69e95655563c2a34e904faf386a9563ce319b6f
Author: Stefan Bodewig <[email protected]>
AuthorDate: Wed Jul 22 18:59:04 2026 +0200

    use a setter instead of a constructor
---
 .../tools/ant/taskdefs/optional/PropertyFile.java  |  4 +-
 .../tools/ant/util/LayoutPreservingProperties.java | 54 ++++++++--------------
 2 files changed, 21 insertions(+), 37 deletions(-)

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 d911ff341..fef3af613 100644
--- a/src/main/org/apache/tools/ant/taskdefs/optional/PropertyFile.java
+++ b/src/main/org/apache/tools/ant/taskdefs/optional/PropertyFile.java
@@ -192,12 +192,14 @@ public class PropertyFile extends Task {
             // comments and layout
             properties = new Properties();
         } else {
+            LayoutPreservingProperties p = new LayoutPreservingProperties();
             Map.Entry<Date, Boolean> now = DateUtils.getNow(getProject());
             Calendar c = Calendar.getInstance();
             c.setTime(now.getKey());
             TimeZone tz = Boolean.TRUE.equals(now.getValue())
                 ? TimeZone.getTimeZone("UTC") : null;
-            properties = new LayoutPreservingProperties(c, tz);
+            p.setDateComment(c, tz);
+            properties = p;
         }
         try {
             if (propertyfile.exists()) {
diff --git a/src/main/org/apache/tools/ant/util/LayoutPreservingProperties.java 
b/src/main/org/apache/tools/ant/util/LayoutPreservingProperties.java
index 95f1aaeb1..5436bae13 100644
--- a/src/main/org/apache/tools/ant/util/LayoutPreservingProperties.java
+++ b/src/main/org/apache/tools/ant/util/LayoutPreservingProperties.java
@@ -105,30 +105,14 @@ public class LayoutPreservingProperties extends 
Properties {
      */
     private boolean removeComments;
 
-    private final Calendar calendar;
-    private final TimeZone tz;
+    private Calendar calendar;
+    private TimeZone tz;
 
     /**
      * Create a new, empty, Properties collection, with no defaults.
      */
     public LayoutPreservingProperties() {
-        this(null, null);
-    }
-
-    /**
-     * Create a new, empty, Properties collection, with no defaults.
-     *
-     * @param calendar date to use for the date comment - defaults to now if 
not set
-     * @param tz timezone to use for the date comment - defaults to
-     * date's timezone if not set and the system's current timezone if
-     * date isn't set either
-     *
-     * @since Ant 1.10.18
-     */
-    public LayoutPreservingProperties(Calendar calendar, TimeZone tz) {
         super();
-        this.calendar = calendar;
-        this.tz = tz;
     }
 
     /**
@@ -136,25 +120,8 @@ public class LayoutPreservingProperties extends Properties 
{
      * @param defaults the default property values
      */
     public LayoutPreservingProperties(final Properties defaults) {
-        this(defaults, null, null);
-    }
-
-    /**
-     * Create a new, empty, Properties collection, with the specified defaults.
-     *
-     * @param defaults the default property values
-     * @param calendar date to use for the date comment - defaults to now if 
not set
-     * @param tz timezone to use for the date comment - defaults to
-     * date's timezone if not set and the system's current timezone if
-     * date isn't set either
-     *
-     * @since Ant 1.10.18
-     */
-    public LayoutPreservingProperties(final Properties defaults, Calendar 
calendar, TimeZone tz) {
         super(defaults);
-        this.calendar = calendar;
-        this.tz = tz;
-   }
+    }
 
     /**
      * Returns <code>true</code> if comments are removed along with
@@ -181,6 +148,21 @@ public class LayoutPreservingProperties extends Properties 
{
         removeComments = val;
     }
 
+    /**
+     * Configures the date and timezone to use for the date comment.
+     *
+     * @param calendar date to use for the date comment - defaults to now if 
not set
+     * @param tz timezone to use for the date comment - defaults to
+     * date's timezone if not set and the system's current timezone if
+     * date isn't set either
+     *
+     * @since Ant 1.10.18
+     */
+    public void setDateComment(Calendar calendar, TimeZone tz) {
+        this.calendar = calendar;
+        this.tz = tz;
+    }
+
     @Override
     public void load(final InputStream inStream) throws IOException {
         final String s = readLines(inStream);

Reply via email to