Browse Source

don't expand properties twice in attributes of macrodef'ed tasks

git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@1204961 13f79535-47bb-0310-9956-ffa450edef68
master
Stefan Bodewig 13 years ago
parent
commit
7d1ecbc1bb
7 changed files with 53 additions and 7 deletions
  1. +3
    -2
      CONTRIBUTORS
  2. +4
    -0
      WHATSNEW
  3. +4
    -0
      contributors.xml
  4. +10
    -2
      src/main/org/apache/tools/ant/RuntimeConfigurable.java
  5. +11
    -0
      src/tests/antunit/taskdefs/macrodef-test.xml
  6. +2
    -2
      src/tests/antunit/taskdefs/property-test.xml
  7. +19
    -1
      src/tests/antunit/taskdefs/propertyhelper-test.xml

+ 3
- 2
CONTRIBUTORS View File

@@ -202,11 +202,12 @@ Marcel Schutte
Marcus Börger Marcus Börger
Mario Frasca Mario Frasca
Mariusz Nowostawski Mariusz Nowostawski
Mark A. Ziesemer
Mark DeLaFranier Mark DeLaFranier
Mark Hecker Mark Hecker
Mark Salter
Mark R. Diggory Mark R. Diggory
Mark A. Ziesemer
Mark Salter
Markus Kahl
Martijn Kruithof Martijn Kruithof
Martin Landers Martin Landers
Martin Poeschl Martin Poeschl


+ 4
- 0
WHATSNEW View File

@@ -104,6 +104,10 @@ Fixed bugs:
* packagemapper now honors the handleDirSep attribute. * packagemapper now honors the handleDirSep attribute.
Bugzilla Report 51068. Bugzilla Report 51068.


* the attributes of macrodef tasks had their values run through
property expansion twice.
Bugzilla Report 42046.

Other changes: Other changes:
-------------- --------------




+ 4
- 0
contributors.xml View File

@@ -860,6 +860,10 @@
<middle>A.</middle> <middle>A.</middle>
<last>Ziesemer</last> <last>Ziesemer</last>
</name> </name>
<name>
<first>Markus</first>
<last>Kahl</last>
</name>
<name> <name>
<first>Martijn</first> <first>Martijn</first>
<last>Kruithof</last> <last>Kruithof</last>


+ 10
- 2
src/main/org/apache/tools/ant/RuntimeConfigurable.java View File

@@ -29,6 +29,7 @@ import java.util.Map;
import java.util.Iterator; import java.util.Iterator;


import org.apache.tools.ant.util.CollectionUtils; import org.apache.tools.ant.util.CollectionUtils;
import org.apache.tools.ant.taskdefs.MacroInstance;
import org.xml.sax.AttributeList; import org.xml.sax.AttributeList;
import org.xml.sax.helpers.AttributeListImpl; import org.xml.sax.helpers.AttributeListImpl;


@@ -382,8 +383,15 @@ public class RuntimeConfigurable implements Serializable {
String name = (String) entry.getKey(); String name = (String) entry.getKey();
String value = (String) entry.getValue(); String value = (String) entry.getValue();


// reflect these into the target
Object attrValue = PropertyHelper.getPropertyHelper(p).parseProperties(value);
// reflect these into the target, defer for
// MacroInstance where properties are expanded for the
// nested sequential
Object attrValue = null;
if (target instanceof MacroInstance) {
attrValue = value;
} else {
attrValue = PropertyHelper.getPropertyHelper(p).parseProperties(value);
}
try { try {
ih.setAttribute(p, target, name, attrValue); ih.setAttribute(p, target, name, attrValue);
} catch (UnsupportedAttributeException be) { } catch (UnsupportedAttributeException be) {


+ 11
- 0
src/tests/antunit/taskdefs/macrodef-test.xml View File

@@ -33,5 +33,16 @@
<au:assertLogContains text="THIS IS NOT DEFAULT LOG"/> <au:assertLogContains text="THIS IS NOT DEFAULT LOG"/>
</target> </target>


<target name="testDoubleExpandedProperties"
description="https://issues.apache.org/bugzilla/show_bug.cgi?id=42046">
<macrodef name="indirect">
<attribute name="value"/>
<sequential>
<echo message="@{value}"/>
</sequential>
</macrodef>
<indirect value="$${basedir}"/>
<au:assertLogContains text="{basedir}"/>
</target>


</project> </project>

+ 2
- 2
src/tests/antunit/taskdefs/property-test.xml View File

@@ -101,8 +101,8 @@ y=$${bar.x}
<property file="${input}/z.properties" prefix="bar"/> <property file="${input}/z.properties" prefix="bar"/>
<!-- passes in Ant 1.7.1 and 1.8.1, fails in 1.8.0 --> <!-- passes in Ant 1.7.1 and 1.8.1, fails in 1.8.0 -->
<!--echo>bar.y is ${bar.y}</echo> <!--echo>bar.y is ${bar.y}</echo>
<au:assertLogContains text="bar.y is y"/-->
<au:assertPropertyEquals name="bar.y" value="y"/>
<au:assertLogContains text="bar.y is y"/>
<au:assertPropertyEquals name="bar.y" value="y"/-->
</target> </target>


<!-- passes in Ant 1.7.1 and 1.8.1, fails in 1.8.0 --> <!-- passes in Ant 1.7.1 and 1.8.1, fails in 1.8.0 -->


+ 19
- 1
src/tests/antunit/taskdefs/propertyhelper-test.xml View File

@@ -107,7 +107,7 @@
</au:assertTrue> </au:assertTrue>
</target> </target>


<target name="testLoadProperties" if="prereqs-ok">
<target name="XtestLoadPropertiesWithObjects" if="prereqs-ok" depends="setUp">
<au:assertFalse> <au:assertFalse>
<isset property="object2" /> <isset property="object2" />
</au:assertFalse> </au:assertFalse>
@@ -125,4 +125,22 @@
<au:assertPropertyEquals name="object2" value="${OBJECT}" /> <au:assertPropertyEquals name="object2" value="${OBJECT}" />
</target> </target>


<target name="testLoadPropertiesWithStrings" if="prereqs-ok" depends="setUp">
<au:assertFalse>
<isset property="string2" />
</au:assertFalse>
<string id="props" value="string2=$${string}" />
<!-- verify the property is not yet expanded -->
<au:assertTrue>
<length length="17">
<resource refid="props" />
</length>
</au:assertTrue>
<loadproperties>
<resource refid="props" />
</loadproperties>
<au:assertPropertyEquals name="string2" value="${string}" />
<au:assertPropertyEquals name="string2" value="${STRING}" />
</target>

</project> </project>

Loading…
Cancel
Save