git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@808449 13f79535-47bb-0310-9956-ffa450edef68master
@@ -936,6 +936,9 @@ Other changes: | |||||
* <path> can now optionally cache its contents. | * <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 | Changes from Ant 1.7.0 TO Ant 1.7.1 | ||||
============================================= | ============================================= | ||||
@@ -31,9 +31,10 @@ | |||||
resource) in the project. Properties are case sensitive.</p> | resource) in the project. Properties are case sensitive.</p> | ||||
Properties are immutable: whoever sets a property first freezes it for the | Properties are immutable: whoever sets a property first freezes it for the | ||||
rest of the build; they are most definitely not variables. | 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> | <ul> | ||||
<li>By supplying both the <i>name</i> and <i>value</i> attribute.</li> | <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 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 | <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 | file to load. This property file has the format as defined by the file used | ||||
@@ -86,8 +87,8 @@ SYSTEM). | |||||
<tr> | <tr> | ||||
<td valign="top">value</td> | <td valign="top">value</td> | ||||
<td valign="top">the value of the property.</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> | ||||
<tr> | <tr> | ||||
<td valign="top">location</td> | <td valign="top">location</td> | ||||
@@ -165,6 +166,9 @@ href="../using.html#path">PATH like structure</a> and can also be set via a nest | |||||
<pre> <property name="foo.dist" value="dist"/></pre> | <pre> <property name="foo.dist" value="dist"/></pre> | ||||
<p>sets the property <code>foo.dist</code> to the value "dist".</p> | <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> | <pre> <property file="foo.properties"/></pre> | ||||
<p>reads a set of properties from a file called "foo.properties".</p> | <p>reads a set of properties from a file called "foo.properties".</p> | ||||
@@ -44,13 +44,17 @@ import org.apache.tools.ant.property.ResolvePropertyMap; | |||||
* resource) in the project. </p> | * resource) in the project. </p> | ||||
* Properties are immutable: whoever sets a property first freezes it for the | * Properties are immutable: whoever sets a property first freezes it for the | ||||
* rest of the build; they are most definitely not variable. | * 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> | * <ul> | ||||
* <li>By supplying both the <i>name</i> and <i>value</i> attribute.</li> | * <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 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 | * <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 | * file to load. This property file has the format as defined by the file used | ||||
* in the class java.util.Properties.</li> | * 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 | * <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 | * property file to load. This property file has the format as defined by the | ||||
* file used in the class java.util.Properties.</li> | * file used in the class java.util.Properties.</li> | ||||
@@ -172,6 +176,20 @@ public class Property extends Task { | |||||
setValue((Object) value); | 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. | * Get the property value. | ||||
* @return the property value | * @return the property value | ||||
@@ -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> |