You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@ant.apache.org by bo...@apache.org on 2012/02/12 10:53:05 UTC
svn commit: r1243221 - in /ant/site/ant: production/faq.html sources/faq.xml
Author: bodewig
Date: Sun Feb 12 09:53:05 2012
New Revision: 1243221
URL: http://svn.apache.org/viewvc?rev=1243221&view=rev
Log:
create a FAQ out of issue 42046
Modified:
ant/site/ant/production/faq.html
ant/site/ant/sources/faq.xml
Modified: ant/site/ant/production/faq.html
URL: http://svn.apache.org/viewvc/ant/site/ant/production/faq.html?rev=1243221&r1=1243220&r2=1243221&view=diff
==============================================================================
--- ant/site/ant/production/faq.html (original)
+++ ant/site/ant/production/faq.html Sun Feb 12 09:53:05 2012
@@ -367,6 +367,10 @@
My <code><junit></code> reports are missing the first line
containing the failure message.
</a></li>
+ <li><a href="#macrodef-property-expansion">
+ Properties are expanded twice in
+ my <code>macrodef</code>ed tasks.
+ </a></li>
</ul>
<h4 class="toc">Apache Ant and IDEs/Editors</h4>
<ul>
@@ -1547,6 +1551,41 @@ shell-prompt> m4 foo.m4 > foo
<p>The only existing work-arounds are to
disable <code>filtertrace</code> or change the failure
message to not contain the word "more".</p>
+ <p class="faq">
+ <a name="macrodef-property-expansion"></a>
+ Properties are expanded twice in
+ my <code>macrodef</code>ed tasks.
+ </p>
+ <p>If your <code>macrodef</code>ed tasks contains attributes,
+ property references are expanded twice, for example</p>
+ <pre class="code">
+ <macrodef name="echotest">
+ <attribute name="message" />
+ <sequential>
+ <echo message="@{message}" />
+ </sequential>
+ </macrodef>
+ <echotest message="$${basedir}" />
+</pre>
+ <p>echos the value of the basedir property rather than the
+ text ${basedir} one would expect. This is
+ a <a href="https://issues.apache.org/bugzilla/show_bug.cgi?id=42046">known
+ issue</a>.</p>
+ <p>It happens because <code>${}</code> sequences are expanded
+ once before expanding <code>@{}</code> sequences and once
+ afterwards. This is required to make things like the
+ macrodef
+ in <a href="#propertyvalue-as-name-for-property">this
+ FAQ</a> work. It enables</p>
+ <pre class="code">
+<property name="choice" value="2"/>
+<property name="thing.1" value="one"/>
+<property name="thing.2" value="two"/>
+<property name="thing.3" value="three"/>
+<propertycopy to="thing" from="thing.${choice}"/>
+</pre>
+ <p>which wouldn't be possible if properties weren't expanded
+ twice.</p>
<p class="faq">
<a name="integration"></a>
Is Apache Ant supported by my IDE/Editor?
Modified: ant/site/ant/sources/faq.xml
URL: http://svn.apache.org/viewvc/ant/site/ant/sources/faq.xml?rev=1243221&r1=1243220&r2=1243221&view=diff
==============================================================================
--- ant/site/ant/sources/faq.xml (original)
+++ ant/site/ant/sources/faq.xml Sun Feb 12 09:53:05 2012
@@ -1129,6 +1129,49 @@ shell-prompt> m4 foo.m4 > foo
message to not contain the word "more".</p>
</answer>
</faq>
+
+ <faq id="macrodef-property-expansion">
+ <question>Properties are expanded twice in
+ my <code>macrodef</code>ed tasks.</question>
+ <answer>
+
+ <p>If your <code>macrodef</code>ed tasks contains attributes,
+ property references are expanded twice, for example</p>
+
+<source><![CDATA[
+ <macrodef name="echotest">
+ <attribute name="message" />
+ <sequential>
+ <echo message="@{message}" />
+ </sequential>
+ </macrodef>
+ <echotest message="$${basedir}" />
+]]></source>
+
+ <p>echos the value of the basedir property rather than the
+ text ${basedir} one would expect. This is
+ a <a href="https://issues.apache.org/bugzilla/show_bug.cgi?id=42046">known
+ issue</a>.</p>
+
+ <p>It happens because <code>${}</code> sequences are expanded
+ once before expanding <code>@{}</code> sequences and once
+ afterwards. This is required to make things like the
+ macrodef
+ in <a href="#propertyvalue-as-name-for-property">this
+ FAQ</a> work. It enables</p>
+
+<source><![CDATA[
+<property name="choice" value="2"/>
+<property name="thing.1" value="one"/>
+<property name="thing.2" value="two"/>
+<property name="thing.3" value="three"/>
+<propertycopy to="thing" from="thing.${choice}"/>
+]]></source>
+
+ <p>which wouldn't be possible if properties weren't expanded
+ twice.</p>
+ </answer>
+ </faq>
</faqsection>
<faqsection title="Apache Ant and IDEs/Editors">