ant-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bode...@apache.org
Subject svn commit: r1243221 - in /ant/site/ant: production/faq.html sources/faq.xml
Date Sun, 12 Feb 2012 09:53:05 GMT
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>&lt;junit&gt;</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&gt; m4 foo.m4 &gt; 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">
+  &lt;macrodef name=&quot;echotest&quot;&gt;
+    &lt;attribute name=&quot;message&quot; /&gt;
+    &lt;sequential&gt;
+      &lt;echo message=&quot;@{message}&quot; /&gt;
+    &lt;/sequential&gt;
+  &lt;/macrodef&gt;
+  &lt;echotest message=&quot;$${basedir}&quot; /&gt;
+</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">
+&lt;property name=&quot;choice&quot; value=&quot;2&quot;/&gt;
+&lt;property name=&quot;thing.1&quot; value=&quot;one&quot;/&gt;
+&lt;property name=&quot;thing.2&quot; value=&quot;two&quot;/&gt;
+&lt;property name=&quot;thing.3&quot; value=&quot;three&quot;/&gt;
+&lt;propertycopy to=&quot;thing&quot; from=&quot;thing.${choice}&quot;/&gt;
+</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">



Mime
View raw message