Author: jglick
Date: Thu Feb 23 22:15:43 2012
New Revision: 1292985
URL: http://svn.apache.org/viewvc?rev=1292985&view=rev
Log:
#52621: restore default behavior from #42046 for compatibility, but make it
configurable.
Modified:
ant/core/trunk/WHATSNEW
ant/core/trunk/manual/Tasks/macrodef.html
ant/core/trunk/src/main/org/apache/tools/ant/RuntimeConfigurable.java
ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/MacroDef.java
ant/core/trunk/src/tests/antunit/taskdefs/macrodef-test.xml
Modified: ant/core/trunk/WHATSNEW
URL:
http://svn.apache.org/viewvc/ant/core/trunk/WHATSNEW?rev=1292985&r1=1292984&r2=1292985&view=diff
==============================================================================
--- ant/core/trunk/WHATSNEW (original)
+++ ant/core/trunk/WHATSNEW Thu Feb 23 22:15:43 2012
@@ -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
Modified: ant/core/trunk/manual/Tasks/macrodef.html
URL:
http://svn.apache.org/viewvc/ant/core/trunk/manual/Tasks/macrodef.html?rev=1292985&r1=1292984&r2=1292985&view=diff
==============================================================================
--- ant/core/trunk/manual/Tasks/macrodef.html (original)
+++ ant/core/trunk/manual/Tasks/macrodef.html Thu Feb 23 22:15:43 2012
@@ -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>
Modified: ant/core/trunk/src/main/org/apache/tools/ant/RuntimeConfigurable.java
URL:
http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/RuntimeConfigurable.java?rev=1292985&r1=1292984&r2=1292985&view=diff
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/RuntimeConfigurable.java
(original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/RuntimeConfigurable.java Thu
Feb 23 22:15:43 2012
@@ -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 impleme
// 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);
Modified: ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/MacroDef.java
URL:
http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/MacroDef.java?rev=1292985&r1=1292984&r2=1292985&view=diff
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/MacroDef.java
(original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/MacroDef.java Thu Feb
23 22:15:43 2012
@@ -331,6 +331,7 @@ public class MacroDef extends AntlibDefi
private String name;
private String defaultValue;
private String description;
+ private boolean doubleExpanding = true;
/**
* The name of the attribute.
@@ -387,6 +388,25 @@ public class MacroDef extends AntlibDefi
}
/**
+ * 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
*
* @param obj an <code>Object</code> value
Modified: ant/core/trunk/src/tests/antunit/taskdefs/macrodef-test.xml
URL:
http://svn.apache.org/viewvc/ant/core/trunk/src/tests/antunit/taskdefs/macrodef-test.xml?rev=1292985&r1=1292984&r2=1292985&view=diff
==============================================================================
--- ant/core/trunk/src/tests/antunit/taskdefs/macrodef-test.xml (original)
+++ ant/core/trunk/src/tests/antunit/taskdefs/macrodef-test.xml Thu Feb 23
22:15:43 2012
@@ -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>