ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Antoine Levy-Lambert <>
Subject AW: if/else in ANT ???
Date Tue, 30 Sep 2003 21:25:55 GMT
What is easy to do in ant is to take actions based on whether a property is
set or not.
It is not easy to take actions based on the value of a property.

A property with value "" is already set for ant.

If you do want to check for empty strings as property value, you can do this
with the condition task (please read the manual).
Using the condition task, you can set another property or not depending on
whether for instance "2" has "" as value.

A typical usage scenario is :

<target name="check.conditions">
    <condition property="myproperty">
    <!-- your tests are here -->
<target name="someaction" depends="check.conditions" if="myproperty">
    <!-- here some real action like compiling, creating jar files,
downloading files with ftp, ... -->

This may sound difficult, but this is somehow the way ant is designed to be

If you prefer using the more familiar if construct, you can download
ant-contrib which contains an if task.


-----Ursprungliche Nachricht-----
Von: Shailesh Sharma []
Gesendet: Dienstag, 30. September 2003 23:15
An: Ant Users List
Betreff: if/else in ANT ???

How does this work out in ANT:

    <property name="1" value="ONE" />
    <property name="2" value="" />
    <property name="3" value="" />

<check to see which value among the above 3 is NOT null>

if(any of the value is NOT null)

// do something ...


Do you Yahoo!?
The New Yahoo! Shopping - with improved product search

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

View raw message