You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@ant.apache.org by bu...@apache.org on 2012/05/16 14:19:38 UTC
[Bug 53241] New: property substitution in macrodef failing
https://issues.apache.org/bugzilla/show_bug.cgi?id=53241
Priority: P2
Bug ID: 53241
Assignee: notifications@ant.apache.org
Summary: property substitution in macrodef failing
Severity: normal
Classification: Unclassified
Reporter: adam.morgan@radian6.com
Hardware: Macintosh
Status: NEW
Version: 1.8.2
Component: Other
Product: Ant
I have looked through the other property substitution bugs but nothing seems to
quite fit this situation. Also, I can't be sure this isn't a bug in
ant-contrib, since i found it using ant-contrib, but since it is related to
property substitution I assumed ant core. Perhaps I'm mistaken. In any case,
here's the issue as seen in this example snippet:
<?xml version="1.0" encoding="UTF-8"?>
<project name="test" default="" basedir="../">
<path id="classpath">
<fileset dir="${basedir}/lib">
<include name="**/*.jar" />
</fileset>
</path>
<taskdef resource="net/sf/antcontrib/antlib.xml" classpathref="classpath"
/>
<target name="test">
<macro1>execute this</macro1>
</target>
<macrodef name="macro1">
<text name="text" />
<sequential>
<property name="print.this" value="@{text}"/>
<echo message="print.this: ${print.this}"/>
<macro2>${print.this}</macro2>
</sequential>
</macrodef>
<macrodef name="macro2">
<text name="text" />
<sequential>
<echo message="text: @{text}"/>
<shellscript shell="bash" dir=""
outputproperty="output-@{text}">@{text}</shellscript>
<echo message="output-@{text}: ${output-@{text}}"/>
</sequential>
</macrodef>
</project>
and the output:
test:
[echo] print.this: execute this
[echo] text: execute this
[shellscript] Result: 127
[echo] output-execute this: ${output-${print.this}}
notice that the 'text' passed in is not substituted properly when echoed the
last time. somehow, the substitution of the macrodef's @{text} ended up with
the literal ${print.this} instead of the value of that property 'execute this'.
--
You are receiving this mail because:
You are the assignee for the bug.
[Bug 53241] property substitution in macrodef failing
Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=53241
Stefan Bodewig <bo...@apache.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |RESOLVED
Resolution|--- |WONTFIX
OS| |All
--- Comment #1 from Stefan Bodewig <bo...@apache.org> ---
This is what happens: Everytime you write @text in your macro2 it gets replaced
with ${print.this} and them properties get expanded so you see "execute this".
In the last case you end up with ${output-${print.this}} before expansion and
Ant doesn't do any nested peoperty expansion - so this is the expected
behavior.
You should be able to use the props Antlib for a propertyhelper that supports
nested property expansion or rewrite your macro to not nest properties, for
example by using a local property as outputproperty.
--
You are receiving this mail because:
You are the assignee for the bug.