From 6e6aa3020f314a64493a57e08b94de405632f0c6 Mon Sep 17 00:00:00 2001
From: Stefan Bodewig
Date: Thu, 27 Aug 2009 15:09:50 +0000
Subject: [PATCH] support nested text in . PR 32917. Submitted by
Alexey Solofnenko
git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@808449 13f79535-47bb-0310-9956-ffa450edef68
---
WHATSNEW | 3 +++
docs/manual/CoreTasks/property.html | 10 ++++---
.../apache/tools/ant/taskdefs/Property.java | 20 +++++++++++++-
src/tests/antunit/taskdefs/property-test.xml | 26 +++++++++++++++++++
4 files changed, 55 insertions(+), 4 deletions(-)
create mode 100644 src/tests/antunit/taskdefs/property-test.xml
diff --git a/WHATSNEW b/WHATSNEW
index 4f314c04b..94b0dd4ab 100644
--- a/WHATSNEW
+++ b/WHATSNEW
@@ -936,6 +936,9 @@ Other changes:
* can now optionally cache its contents.
+ * can now specify values as nested text.
+ Bugzilla Report 32917.
+
Changes from Ant 1.7.0 TO Ant 1.7.1
=============================================
diff --git a/docs/manual/CoreTasks/property.html b/docs/manual/CoreTasks/property.html
index f6ed34149..b37f27a32 100644
--- a/docs/manual/CoreTasks/property.html
+++ b/docs/manual/CoreTasks/property.html
@@ -31,9 +31,10 @@
resource) in the project. Properties are case sensitive.
Properties are immutable: whoever sets a property first freezes it for the
rest of the build; they are most definitely not variables.
-There are six ways to set properties:
+There are seven ways to set properties:
- By supplying both the name and value attribute.
+ - By supplying the name and nested text.
- By supplying both the name and refid attribute.
- By setting the file attribute with the filename of the property
file to load. This property file has the format as defined by the file used
@@ -86,8 +87,8 @@ SYSTEM).
value |
the value of the property. |
- One of these, when using the
- name attribute |
+ One of these or
+ nested text, when using the name attribute |
location |
@@ -165,6 +166,9 @@ href="../using.html#path">PATH like structure and can also be set via a nest
<property name="foo.dist" value="dist"/>
sets the property foo.dist
to the value "dist".
+ <property name="foo.dist">dist</property>
+sets the property foo.dist
to the value "dist".
+
<property file="foo.properties"/>
reads a set of properties from a file called "foo.properties".
diff --git a/src/main/org/apache/tools/ant/taskdefs/Property.java b/src/main/org/apache/tools/ant/taskdefs/Property.java
index 0eb3bb151..81f621e10 100644
--- a/src/main/org/apache/tools/ant/taskdefs/Property.java
+++ b/src/main/org/apache/tools/ant/taskdefs/Property.java
@@ -44,13 +44,17 @@ import org.apache.tools.ant.property.ResolvePropertyMap;
* resource) in the project.
* Properties are immutable: whoever sets a property first freezes it for the
* rest of the build; they are most definitely not variable.
- * There are five ways to set properties:
+ * There are seven ways to set properties:
*
* - By supplying both the name and value attribute.
+ * - By supplying the name and nested text.
* - By supplying both the name and refid attribute.
* - By setting the file attribute with the filename of the property
* file to load. This property file has the format as defined by the file used
* in the class java.util.Properties.
+ * - By setting the url attribute with the url from which to load the
+ * properties. This url must be directed to a file that has the format as defined
+ * by the file used in the class java.util.Properties.
* - By setting the resource attribute with the resource name of the
* property file to load. This property file has the format as defined by the
* file used in the class java.util.Properties.
@@ -172,6 +176,20 @@ public class Property extends Task {
setValue((Object) value);
}
+ /**
+ * Set a (multiline) property as nested text.
+ * @param msg the text to append to the output text
+ * @since Ant 1.8.0
+ */
+ public void addText(String msg) {
+ msg = getProject().replaceProperties(msg);
+ String currentValue = getValue();
+ if (currentValue != null) {
+ msg = currentValue + msg;
+ }
+ setValue(msg);
+ }
+
/**
* Get the property value.
* @return the property value
diff --git a/src/tests/antunit/taskdefs/property-test.xml b/src/tests/antunit/taskdefs/property-test.xml
new file mode 100644
index 000000000..d1fe3644b
--- /dev/null
+++ b/src/tests/antunit/taskdefs/property-test.xml
@@ -0,0 +1,26 @@
+
+
+
+
+
+
+
+ bar
+
+
+