ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "David Weintraub" <>
Subject Re: ANT / AntXtras quick question.
Date Tue, 18 Sep 2007 01:22:48 GMT
Try the "isset" task of the <condition> task. It can be used with the <if> task

    <isset property="myprop"/>
             message="Property &quot;myprop&quot; is set and is equal
to ${myprop}"/>
        <echo message="Property &quot;myprop&quot; isn't set"/>

You could also use equals:

    <equals arg1="${myprop}" arg2=""/>

The <if> task is part of antcontrib at Otherwise, look at the
<condition> task. The <condition> task allows you to set a property if
a particular condition is met and that includes both the <isset> and
<equals> parameters. You can then combine this with <antcall> and
targets with conditions:

<condition property="myprop.flag">
    <isset property="myprop"/>
<antcall target="myprop.isset"/>
<antcall target="myprop.notset"/>

<target name="myprop.isset" if="myprop.isset"/>
<target name="myprop.notset" unless="myprop.isset"/>

Yes, in this particular instance, you can simply test the property
directly in the tasks, but this does show you how you can set a
property on the <condition> task, then use that as an if/else
statement without using the antcontrib tasks.

On 9/17/07, warhero <> wrote:
> I'm having trouble trying to figure out how to make sure a property is not
> empty.
> So I have a properties file like so
> myprop=something.
> And if the myprop is not empty (myprop=) then execute something. Does that
> make sense? here's some kind of pseudocode.
> <if myprop != ''>
>   <exec whatever>
> </if>
> Just some pseudo code, but get's the point across..
> Thanks in advance.
> --
> View this message in context:
> Sent from the Ant - Users mailing list archive at
> ---------------------------------------------------------------------
> To unsubscribe, e-mail:
> For additional commands, e-mail:

David Weintraub

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message