Try the "isset" task of the <condition> task. It can be used with the <if> task

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

You could also use equals:

<if>
    <equals arg1="${myprop}" arg2=""/>
    <then>
    [...]

The <if> task is part of antcontrib at
http://ant-contrib.sourceforge.net/. 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"/>
</condition>
<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 <[EMAIL PROTECTED]> 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: 
> http://www.nabble.com/ANT---AntXtras-quick-question.-tf4470947.html#a12747996
> Sent from the Ant - Users mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>


-- 
--
David Weintraub
[EMAIL PROTECTED]

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to