Author: bodewig
Date: Thu Aug 27 15:09:50 2009
New Revision: 808449
URL: http://svn.apache.org/viewvc?rev=808449&view=rev
Log:
support nested text in <property>. PR 32917. Submitted by Alexey Solofnenko
Added:
ant/core/trunk/src/tests/antunit/taskdefs/property-test.xml (with props)
Modified:
ant/core/trunk/WHATSNEW
ant/core/trunk/docs/manual/CoreTasks/property.html
ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Property.java
Modified: ant/core/trunk/WHATSNEW
URL:
http://svn.apache.org/viewvc/ant/core/trunk/WHATSNEW?rev=808449&r1=808448&r2=808449&view=diff
==============================================================================
--- ant/core/trunk/WHATSNEW (original)
+++ ant/core/trunk/WHATSNEW Thu Aug 27 15:09:50 2009
@@ -936,6 +936,9 @@
* <path> can now optionally cache its contents.
+ * <property> can now specify values as nested text.
+ Bugzilla Report 32917.
+
Changes from Ant 1.7.0 TO Ant 1.7.1
=============================================
Modified: ant/core/trunk/docs/manual/CoreTasks/property.html
URL:
http://svn.apache.org/viewvc/ant/core/trunk/docs/manual/CoreTasks/property.html?rev=808449&r1=808448&r2=808449&view=diff
==============================================================================
--- ant/core/trunk/docs/manual/CoreTasks/property.html (original)
+++ ant/core/trunk/docs/manual/CoreTasks/property.html Thu Aug 27 15:09:50 2009
@@ -31,9 +31,10 @@
resource) in the project. Properties are case sensitive.</p>
Properties are immutable: whoever sets a property first freezes it for the
rest of the build; they are most definitely not variables.
-<p>There are six ways to set properties:</p>
+<p>There are seven ways to set properties:</p>
<ul>
<li>By supplying both the <i>name</i> and <i>value</i> attribute.</li>
+ <li>By supplying the <i>name</i> and nested text.</li>
<li>By supplying both the <i>name</i> and <i>refid</i> attribute.</li>
<li>By setting the <i>file</i> 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 @@
<tr>
<td valign="top">value</td>
<td valign="top">the value of the property.</td>
- <td valign="middle" align="center" rowspan="3">One of these, when using the
- name attribute</td>
+ <td valign="middle" align="center" rowspan="3">One of these or
+ nested text, when using the name attribute</td>
</tr>
<tr>
<td valign="top">location</td>
@@ -165,6 +166,9 @@
<pre> <property name="foo.dist" value="dist"/></pre>
<p>sets the property <code>foo.dist</code> to the value "dist".</p>
+<pre> <property name="foo.dist">dist</property></pre>
+<p>sets the property <code>foo.dist</code> to the value "dist".</p>
+
<pre> <property file="foo.properties"/></pre>
<p>reads a set of properties from a file called "foo.properties".</p>
Modified: ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Property.java
URL:
http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Property.java?rev=808449&r1=808448&r2=808449&view=diff
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Property.java
(original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Property.java Thu Aug
27 15:09:50 2009
@@ -44,13 +44,17 @@
* resource) in the project. </p>
* Properties are immutable: whoever sets a property first freezes it for the
* rest of the build; they are most definitely not variable.
- * <p>There are five ways to set properties:</p>
+ * <p>There are seven ways to set properties:</p>
* <ul>
* <li>By supplying both the <i>name</i> and <i>value</i> attribute.</li>
+ * <li>By supplying the <i>name</i> and nested text.</li>
* <li>By supplying both the <i>name</i> and <i>refid</i> attribute.</li>
* <li>By setting the <i>file</i> 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.</li>
+ * <li>By setting the <i>url</i> 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.</li>
* <li>By setting the <i>resource</i> 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.</li>
@@ -173,6 +177,20 @@
}
/**
+ * 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
*/
Added: ant/core/trunk/src/tests/antunit/taskdefs/property-test.xml
URL:
http://svn.apache.org/viewvc/ant/core/trunk/src/tests/antunit/taskdefs/property-test.xml?rev=808449&view=auto
==============================================================================
--- ant/core/trunk/src/tests/antunit/taskdefs/property-test.xml (added)
+++ ant/core/trunk/src/tests/antunit/taskdefs/property-test.xml Thu Aug 27
15:09:50 2009
@@ -0,0 +1,26 @@
+<?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="testNestedText">
+ <property name="foo">bar</property>
+ <au:assertPropertyEquals name="foo" value="bar"/>
+ </target>
+</project>
Propchange: ant/core/trunk/src/tests/antunit/taskdefs/property-test.xml
------------------------------------------------------------------------------
svn:eol-style = native