You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@ant.apache.org by bo...@apache.org on 2017/05/08 16:46:14 UTC
[1/3] ant git commit: fix off by one error found by Matt Benson
Repository: ant
Updated Branches:
refs/heads/master 2ec41afdc -> 966708a29
fix off by one error found by Matt Benson
Project: http://git-wip-us.apache.org/repos/asf/ant/repo
Commit: http://git-wip-us.apache.org/repos/asf/ant/commit/e293c7a2
Tree: http://git-wip-us.apache.org/repos/asf/ant/tree/e293c7a2
Diff: http://git-wip-us.apache.org/repos/asf/ant/diff/e293c7a2
Branch: refs/heads/master
Commit: e293c7a29c9dea995dea2868b9cb2f53b5b304e0
Parents: 5347475
Author: Stefan Bodewig <bo...@apache.org>
Authored: Fri Apr 21 21:35:46 2017 +0200
Committer: Stefan Bodewig <bo...@apache.org>
Committed: Fri Apr 21 21:35:46 2017 +0200
----------------------------------------------------------------------
src/main/org/apache/tools/ant/helper/ProjectHelper2.java | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ant/blob/e293c7a2/src/main/org/apache/tools/ant/helper/ProjectHelper2.java
----------------------------------------------------------------------
diff --git a/src/main/org/apache/tools/ant/helper/ProjectHelper2.java b/src/main/org/apache/tools/ant/helper/ProjectHelper2.java
index 67e1dec..2e9c725 100644
--- a/src/main/org/apache/tools/ant/helper/ProjectHelper2.java
+++ b/src/main/org/apache/tools/ant/helper/ProjectHelper2.java
@@ -256,7 +256,7 @@ public class ProjectHelper2 extends ProjectHelper {
zf = new ZipFile(org.apache.tools.ant.launch.Locator
.fromJarURI(uri), "UTF-8");
inputStream =
- zf.getInputStream(zf.getEntry(uri.substring(pling + 1)));
+ zf.getInputStream(zf.getEntry(uri.substring(pling + 2)));
} else {
URLConnection conn = url.openConnection();
conn.setUseCaches(false);
[2/3] ant git commit: add magic property that override's tstamp's
idea of "now"
Posted by bo...@apache.org.
add magic property that override's tstamp's idea of "now"
https://bz.apache.org/bugzilla/show_bug.cgi?id=61079
Project: http://git-wip-us.apache.org/repos/asf/ant/repo
Commit: http://git-wip-us.apache.org/repos/asf/ant/commit/7c6c749c
Tree: http://git-wip-us.apache.org/repos/asf/ant/tree/7c6c749c
Diff: http://git-wip-us.apache.org/repos/asf/ant/diff/7c6c749c
Branch: refs/heads/master
Commit: 7c6c749c952153170e82b791d97086e99fe2a3cb
Parents: e293c7a
Author: Stefan Bodewig <bo...@apache.org>
Authored: Mon May 8 18:44:07 2017 +0200
Committer: Stefan Bodewig <bo...@apache.org>
Committed: Mon May 8 18:44:07 2017 +0200
----------------------------------------------------------------------
WHATSNEW | 4 +++
manual/Tasks/tstamp.html | 6 +++++
manual/running.html | 5 ++++
src/main/org/apache/tools/ant/MagicNames.java | 13 ++++++++++
.../org/apache/tools/ant/taskdefs/Tstamp.java | 19 +++++++++++++-
src/tests/antunit/taskdefs/tstamp-test.xml | 27 ++++++++++++++++++++
6 files changed, 73 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ant/blob/7c6c749c/WHATSNEW
----------------------------------------------------------------------
diff --git a/WHATSNEW b/WHATSNEW
index 9dac453..aa2ad03 100644
--- a/WHATSNEW
+++ b/WHATSNEW
@@ -18,6 +18,10 @@ Other changes:
* added "regexp" attribute to <linecontainsregexp>
Bugzilla Report 60968
+ * added a new magic property ant.tstamp.now that can be used to
+ override the current time/date used by <tstamp>.
+ Bugzilla Report 61079
+
Changes from Ant 1.9.8 TO Ant 1.9.9
===================================
http://git-wip-us.apache.org/repos/asf/ant/blob/7c6c749c/manual/Tasks/tstamp.html
----------------------------------------------------------------------
diff --git a/manual/Tasks/tstamp.html b/manual/Tasks/tstamp.html
index 82812a5..6baa0c8 100644
--- a/manual/Tasks/tstamp.html
+++ b/manual/Tasks/tstamp.html
@@ -40,6 +40,12 @@ time-stamped filenames, or used to replace placeholder tags inside documents
to indicate, for example, the release date. The best place for this task is
probably in an initialization target.</p>
+<p><em>Since Ant 1.9.10</em> the magic
+ property <code>ant.tstamp.now</code> can be used to specify a fixed
+ date value in order to create reproducible builds. Its value must be
+ a number and is interpreted as seconds since the epoch (midnight
+ 1970-01-01).</p>
+
<h3>Parameters</h3>
<table border="1" cellpadding="2" cellspacing="0">
<tr>
http://git-wip-us.apache.org/repos/asf/ant/blob/7c6c749c/manual/running.html
----------------------------------------------------------------------
diff --git a/manual/running.html b/manual/running.html
index 529afc7..3bfb500 100644
--- a/manual/running.html
+++ b/manual/running.html
@@ -485,6 +485,11 @@ org.apache.tools.ant.Executor implementation specified here.
<a href="argumentprocessor.html#repository">ArgumentProcessor internal repository</a>.
</td>
</tr>
+<tr>
+ <td><code>ant.tstamp.now</code></td>
+ <td>number, seconds since the epoch (midnight 1970-01-01)</td>
+ <td>The value to use as current time and date for <tstamp></td>
+</tr>
</table>
<p>
http://git-wip-us.apache.org/repos/asf/ant/blob/7c6c749c/src/main/org/apache/tools/ant/MagicNames.java
----------------------------------------------------------------------
diff --git a/src/main/org/apache/tools/ant/MagicNames.java b/src/main/org/apache/tools/ant/MagicNames.java
index bc39a25..67ab8a8 100644
--- a/src/main/org/apache/tools/ant/MagicNames.java
+++ b/src/main/org/apache/tools/ant/MagicNames.java
@@ -289,5 +289,18 @@ public final class MagicNames {
* Value {@value}
*/
public static final String HTTP_AGENT_PROPERTY = "ant.http.agent";
+
+ /**
+ * Magic property that can be set to contain a value for tstamp's
+ * "now" in order to make builds that use the task create
+ * reproducible results.
+ *
+ * <p>The value is expected to be a number representing the date
+ * as seconds since the epoch.</p>
+ *
+ * Value: {@value}
+ * @since Ant 1.9.10
+ */
+ public static final String TSTAMP_NOW = "ant.tstamp.now";
}
http://git-wip-us.apache.org/repos/asf/ant/blob/7c6c749c/src/main/org/apache/tools/ant/taskdefs/Tstamp.java
----------------------------------------------------------------------
diff --git a/src/main/org/apache/tools/ant/taskdefs/Tstamp.java b/src/main/org/apache/tools/ant/taskdefs/Tstamp.java
index 805427a..a6a35d7 100644
--- a/src/main/org/apache/tools/ant/taskdefs/Tstamp.java
+++ b/src/main/org/apache/tools/ant/taskdefs/Tstamp.java
@@ -32,6 +32,7 @@ import java.util.Vector;
import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.Location;
+import org.apache.tools.ant.MagicNames;
import org.apache.tools.ant.Project;
import org.apache.tools.ant.Task;
import org.apache.tools.ant.types.EnumeratedAttribute;
@@ -68,7 +69,7 @@ public class Tstamp extends Task {
*/
public void execute() throws BuildException {
try {
- Date d = new Date();
+ Date d = getNow();
Enumeration i = customFormats.elements();
while (i.hasMoreElements()) {
@@ -110,6 +111,22 @@ public class Tstamp extends Task {
}
/**
+ * Return the {@link Date} instance to use as base for DSTAMP, TSTAMP and TODAY.
+ */
+ protected Date getNow() {
+ String magicNow = getProject().getProperty(MagicNames.TSTAMP_NOW);
+ if (magicNow != null && magicNow.length() > 0) {
+ try {
+ return new Date(1000 * Long.parseLong(magicNow));
+ } catch (NumberFormatException ex) {
+ log("magic property " + MagicNames.TSTAMP_NOW + " ignored as "
+ + magicNow + " is not a valid number");
+ }
+ }
+ return new Date();
+ }
+
+ /**
* This nested element that allows a property to be set
* to the current date and time in a given format.
* The date/time patterns are as defined in the
http://git-wip-us.apache.org/repos/asf/ant/blob/7c6c749c/src/tests/antunit/taskdefs/tstamp-test.xml
----------------------------------------------------------------------
diff --git a/src/tests/antunit/taskdefs/tstamp-test.xml b/src/tests/antunit/taskdefs/tstamp-test.xml
new file mode 100644
index 0000000..c9bebf8
--- /dev/null
+++ b/src/tests/antunit/taskdefs/tstamp-test.xml
@@ -0,0 +1,27 @@
+<?xml version="1.0"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<project default="antunit" xmlns:au="antlib:org.apache.ant.antunit">
+ <import file="../antunit-base.xml" />
+
+ <target name="testMagicProperty">
+ <local name="ant.tstamp.now"/>
+ <property name="ant.tstamp.now" value="100000"/>
+ <tstamp/>
+ <au:assertPropertyEquals name="DSTAMP" value="19700102"/>
+ </target>
+</project>
[3/3] ant git commit: Merge branch '1.9.x'
Posted by bo...@apache.org.
Merge branch '1.9.x'
Project: http://git-wip-us.apache.org/repos/asf/ant/repo
Commit: http://git-wip-us.apache.org/repos/asf/ant/commit/966708a2
Tree: http://git-wip-us.apache.org/repos/asf/ant/tree/966708a2
Diff: http://git-wip-us.apache.org/repos/asf/ant/diff/966708a2
Branch: refs/heads/master
Commit: 966708a294a4b731ebfafe4af5da776969919f89
Parents: 2ec41af 7c6c749
Author: Stefan Bodewig <bo...@apache.org>
Authored: Mon May 8 18:45:59 2017 +0200
Committer: Stefan Bodewig <bo...@apache.org>
Committed: Mon May 8 18:45:59 2017 +0200
----------------------------------------------------------------------
WHATSNEW | 4 +++
manual/Tasks/tstamp.html | 6 +++++
manual/running.html | 5 ++++
src/main/org/apache/tools/ant/MagicNames.java | 13 ++++++++++
.../org/apache/tools/ant/taskdefs/Tstamp.java | 19 +++++++++++++-
src/tests/antunit/taskdefs/tstamp-test.xml | 27 ++++++++++++++++++++
6 files changed, 73 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ant/blob/966708a2/WHATSNEW
----------------------------------------------------------------------
diff --cc WHATSNEW
index b552951,aa2ad03..ba2213e
--- a/WHATSNEW
+++ b/WHATSNEW
@@@ -28,15 -18,12 +28,19 @@@ Other changes
* added "regexp" attribute to <linecontainsregexp>
Bugzilla Report 60968
+ * reduced GC pressure by replacing all usage of FileInputStream and
+ FileOutputStream.
+
+ * Task can now also use attribute setters that expect a
+ java.nio.file.Path argument.
+ Bugzilla Report 61042
+
+ * added a new magic property ant.tstamp.now that can be used to
+ override the current time/date used by <tstamp>.
+ Bugzilla Report 61079
+
-Changes from Ant 1.9.8 TO Ant 1.9.9
-===================================
+Changes from Ant 1.10.0 TO Ant 1.10.1
+=====================================
Fixed bugs:
-----------
http://git-wip-us.apache.org/repos/asf/ant/blob/966708a2/manual/Tasks/tstamp.html
----------------------------------------------------------------------
diff --cc manual/Tasks/tstamp.html
index 82812a5,6baa0c8..c9a83c9
--- a/manual/Tasks/tstamp.html
+++ b/manual/Tasks/tstamp.html
@@@ -40,6 -40,12 +40,12 @@@ time-stamped filenames, or used to repl
to indicate, for example, the release date. The best place for this task is
probably in an initialization target.</p>
-<p><em>Since Ant 1.9.10</em> the magic
++<p><em>Since Ant 1.10.2</em> the magic
+ property <code>ant.tstamp.now</code> can be used to specify a fixed
+ date value in order to create reproducible builds. Its value must be
+ a number and is interpreted as seconds since the epoch (midnight
+ 1970-01-01).</p>
+
<h3>Parameters</h3>
<table border="1" cellpadding="2" cellspacing="0">
<tr>
http://git-wip-us.apache.org/repos/asf/ant/blob/966708a2/src/main/org/apache/tools/ant/MagicNames.java
----------------------------------------------------------------------
diff --cc src/main/org/apache/tools/ant/MagicNames.java
index 336c3bc,67ab8a8..5f6aec9
--- a/src/main/org/apache/tools/ant/MagicNames.java
+++ b/src/main/org/apache/tools/ant/MagicNames.java
@@@ -295,5 -289,18 +295,18 @@@ public final class MagicNames
* Value {@value}
*/
public static final String HTTP_AGENT_PROPERTY = "ant.http.agent";
+
+ /**
+ * Magic property that can be set to contain a value for tstamp's
+ * "now" in order to make builds that use the task create
+ * reproducible results.
+ *
+ * <p>The value is expected to be a number representing the date
+ * as seconds since the epoch.</p>
+ *
+ * Value: {@value}
- * @since Ant 1.9.10
++ * @since Ant 1.10.2
+ */
+ public static final String TSTAMP_NOW = "ant.tstamp.now";
}
http://git-wip-us.apache.org/repos/asf/ant/blob/966708a2/src/main/org/apache/tools/ant/taskdefs/Tstamp.java
----------------------------------------------------------------------
diff --cc src/main/org/apache/tools/ant/taskdefs/Tstamp.java
index 0610c39,a6a35d7..98dd779
--- a/src/main/org/apache/tools/ant/taskdefs/Tstamp.java
+++ b/src/main/org/apache/tools/ant/taskdefs/Tstamp.java
@@@ -66,12 -67,15 +67,12 @@@ public class Tstamp extends Task
* the standard ones, to get their retaliation in early.
* @throws BuildException on error.
*/
+ @Override
public void execute() throws BuildException {
try {
- Date d = new Date();
+ Date d = getNow();
- Enumeration i = customFormats.elements();
- while (i.hasMoreElements()) {
- CustomFormat cts = (CustomFormat) i.nextElement();
- cts.execute(getProject(), d, getLocation());
- }
+ customFormats.forEach(cts -> cts.execute(getProject(), d, getLocation()));
SimpleDateFormat dstamp = new SimpleDateFormat ("yyyyMMdd");
setProperty("DSTAMP", dstamp.format(d));