Hi,
Thanks for the feedback. Actually, the use of Ant-Contrib is okay.
But, please note that it isn't just a property that I'd want to set. It's really the ability to look at the "return" values of a
macrodef and use that result with an <if> task. I do realize that a workaround exists in this form:
<macrodef name="mymacrodef">
<element name="if-true"/>
<element name="if-false"/>
<sequential>
... other stuff done by mymacrodef
<if>
... some condition ...
<then>
<if-true/>
</then>
<else>
<if-false/>
</else>
</if>
... other stuff done by mymacrodef ...
</sequential>
</macrodef>
And then used as:
<mymacrodef>
<if-true>...</if-true>
<if-false>...</if-false>
</mymacrodef>
But, this isn't as clean as I'd like. Also, I'd like to be able to add *optional="true"* to the element. But, I don't know how to
check in the macrodef whether an element was actually used or not by the caller (again, in Ant only, possibly with Ant-Contrib).
What do you think? Can you improve on the above workaround?
Thanks,
Steve Amerige
SAS Institute, Deployment Software Development
On 11/8/2011 11:10 AM, Murray, Mike wrote:
Assuming no use of AntContrib, you can pass the name of a property to the Macrodef,
which it would set. This property could then be used in an Ant condition. I'd give
in and use AntContrib though, since it gives you an<if> task.
-----Original Message-----
From: Steve Amerige [mailto:steve.amer...@sas.com]
Sent: Tuesday, November 08, 2011 9:46 AM
To: Ant Users List
Subject: Macrodef and If
I'd like to do something like:
<if>
<mymacrodef/>
<then>
...
</then>
</if>
<macrodef name="mymacrodef">
...
</macrodef>
Within the macrodef, there would be places it would return true and other
places it returns false. I want the solution to be wholly
in Ant (no Java, Groovy, external file use, etc.).
Is it possible? If so, can you show an example of how the mymacrodef would be
coded?
Thanks!
Steve Amerige
SAS Institute, Deployment Software Development