ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Steve Amerige <>
Subject Re: Macrodef and If
Date Tue, 08 Nov 2011 23:30:58 GMT

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"/>
        ... other stuff done by mymacrodef

           ... some condition ...

        ... other stuff done by mymacrodef ...

And then used as:


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?

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 []
> 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

  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message