ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Stefan Bodewig <bode...@apache.org>
Subject Re: Macrodef and If
Date Wed, 09 Nov 2011 04:49:16 GMT
On 2011-11-08, Steve Amerige wrote:

> 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?

No.  macrodef can only be used to define tasks, not conditions (which is
what you'd need).

What you can do is what Mike suggests.  Use your macrodef to set a
property and then use isset as condition inside your if.

    <mymacrodef property="foo"/>
    <if>
    <isset property="foo"/>
    <then>
         ...
    </then>
    </if>

Stefan

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org


Mime
View raw message