Browse Source

#52621: restore default behavior from #42046 for compatibility, but make it configurable.

git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@1292985 13f79535-47bb-0310-9956-ffa450edef68
master
Jesse N. Glick 13 years ago
parent
commit
84abb27b2f
5 changed files with 42 additions and 6 deletions
  1. +1
    -1
      WHATSNEW
  2. +9
    -0
      manual/Tasks/macrodef.html
  3. +11
    -4
      src/main/org/apache/tools/ant/RuntimeConfigurable.java
  4. +20
    -0
      src/main/org/apache/tools/ant/taskdefs/MacroDef.java
  5. +1
    -1
      src/tests/antunit/taskdefs/macrodef-test.xml

+ 1
- 1
WHATSNEW View File

@@ -128,7 +128,7 @@ Fixed bugs:
Bugzilla Report 51086.

* the attributes of macrodef tasks had their values run through
property expansion twice.
property expansion twice. Still true by default, but can be disabled.
Bugzilla Report 42046.

* jvc doesn't like it if source file names in argument files are


+ 9
- 0
manual/Tasks/macrodef.html View File

@@ -128,6 +128,15 @@
</td>
<td valign="top" align="center">No</td>
</tr>
<tr>
<td valign="top">doubleexpanding</td>
<td valign="top">
Controls whether or not property references in the attribute are expanded twice or just once.
See the <a href="http://ant.apache.org/faq.html#macrodef-property-expansion">FAQ</a> for details.
<em>since Ant 1.8.3</em>
</td>
<td valign="top" align="center">No; default true</td>
</tr>
</table>
<h4>element</h4>
<p>


+ 11
- 4
src/main/org/apache/tools/ant/RuntimeConfigurable.java View File

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

import org.apache.tools.ant.util.CollectionUtils;
import org.apache.tools.ant.taskdefs.MacroDef;
import org.apache.tools.ant.taskdefs.MacroInstance;
import org.xml.sax.AttributeList;
import org.xml.sax.helpers.AttributeListImpl;
@@ -386,11 +387,17 @@ public class RuntimeConfigurable implements Serializable {
// reflect these into the target, defer for
// MacroInstance where properties are expanded for the
// nested sequential
Object attrValue = null;
Object attrValue = PropertyHelper.getPropertyHelper(p).parseProperties(value);
if (target instanceof MacroInstance) {
attrValue = value;
} else {
attrValue = PropertyHelper.getPropertyHelper(p).parseProperties(value);
for (Iterator attrs = ((MacroInstance) target).getMacroDef().getAttributes().iterator(); attrs.hasNext();) {
MacroDef.Attribute attr = (MacroDef.Attribute) attrs.next();
if (attr.getName().equals(name)) {
if (!attr.isDoubleExpanding()) {
attrValue = value;
}
break;
}
}
}
try {
ih.setAttribute(p, target, name, attrValue);


+ 20
- 0
src/main/org/apache/tools/ant/taskdefs/MacroDef.java View File

@@ -331,6 +331,7 @@ public class MacroDef extends AntlibDefinition {
private String name;
private String defaultValue;
private String description;
private boolean doubleExpanding = true;

/**
* The name of the attribute.
@@ -386,6 +387,25 @@ public class MacroDef extends AntlibDefinition {
return description;
}

/**
* See {@link #isDoubleExpanding} for explanation.
* @param doubleExpanding true to expand twice, false for just once
* @since Ant 1.8.3
*/
public void setDoubleExpanding(boolean doubleExpanding) {
this.doubleExpanding = doubleExpanding;
}

/**
* Determines whether {@link RuntimeConfigurable#maybeConfigure(Project, boolean)} will reevaluate this property.
* For compatibility reasons (#52621) it will, though for most applications (#42046) it should not.
* @return true if expanding twice (the default), false for just once
* @since Ant 1.8.3
*/
public boolean isDoubleExpanding() {
return doubleExpanding;
}

/**
* equality method
*


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

@@ -36,7 +36,7 @@
<target name="testDoubleExpandedProperties"
description="https://issues.apache.org/bugzilla/show_bug.cgi?id=42046">
<macrodef name="indirect">
<attribute name="value"/>
<attribute name="value" doubleexpanding="false"/>
<sequential>
<echo message="@{value}"/>
</sequential>


Loading…
Cancel
Save