git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@1292985 13f79535-47bb-0310-9956-ffa450edef68master
@@ -128,7 +128,7 @@ Fixed bugs: | |||||
Bugzilla Report 51086. | Bugzilla Report 51086. | ||||
* the attributes of macrodef tasks had their values run through | * 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. | Bugzilla Report 42046. | ||||
* jvc doesn't like it if source file names in argument files are | * jvc doesn't like it if source file names in argument files are | ||||
@@ -128,6 +128,15 @@ | |||||
</td> | </td> | ||||
<td valign="top" align="center">No</td> | <td valign="top" align="center">No</td> | ||||
</tr> | </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> | </table> | ||||
<h4>element</h4> | <h4>element</h4> | ||||
<p> | <p> | ||||
@@ -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.MacroDef; | |||||
import org.apache.tools.ant.taskdefs.MacroInstance; | 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; | ||||
@@ -386,11 +387,17 @@ public class RuntimeConfigurable implements Serializable { | |||||
// reflect these into the target, defer for | // reflect these into the target, defer for | ||||
// MacroInstance where properties are expanded for the | // MacroInstance where properties are expanded for the | ||||
// nested sequential | // nested sequential | ||||
Object attrValue = null; | |||||
Object attrValue = PropertyHelper.getPropertyHelper(p).parseProperties(value); | |||||
if (target instanceof MacroInstance) { | 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 { | try { | ||||
ih.setAttribute(p, target, name, attrValue); | ih.setAttribute(p, target, name, attrValue); | ||||
@@ -331,6 +331,7 @@ public class MacroDef extends AntlibDefinition { | |||||
private String name; | private String name; | ||||
private String defaultValue; | private String defaultValue; | ||||
private String description; | private String description; | ||||
private boolean doubleExpanding = true; | |||||
/** | /** | ||||
* The name of the attribute. | * The name of the attribute. | ||||
@@ -386,6 +387,25 @@ public class MacroDef extends AntlibDefinition { | |||||
return description; | 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 | * equality method | ||||
* | * | ||||
@@ -36,7 +36,7 @@ | |||||
<target name="testDoubleExpandedProperties" | <target name="testDoubleExpandedProperties" | ||||
description="https://issues.apache.org/bugzilla/show_bug.cgi?id=42046"> | description="https://issues.apache.org/bugzilla/show_bug.cgi?id=42046"> | ||||
<macrodef name="indirect"> | <macrodef name="indirect"> | ||||
<attribute name="value"/> | |||||
<attribute name="value" doubleexpanding="false"/> | |||||
<sequential> | <sequential> | ||||
<echo message="@{value}"/> | <echo message="@{value}"/> | ||||
</sequential> | </sequential> | ||||