ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Qazwart <qazw...@gmail.com>
Subject Re: Simple if/else Condition
Date Wed, 18 Jul 2007 04:14:13 GMT

On Jul 17, 2007, at 11:18 PM, Evan J wrote:
> if (condition)
>  perform some task, i.e. echo message="condition met"
> else
>  perform another task

Check out the AntContrib tasks at <http://ant-contrib.sourceforge.net/ 
tasks/tasks/index.html>.
There is actually an <if> ant task at <http://ant- 
contrib.sourceforge.net/tasks/tasks/if.html>. I've used it quite  
successfully with Ant 1.7.

If you don't want to use optional tasks, you can use the <condition>  
task like this to emulate an <if><else> task:

<condition
     property="os_is_windows"
     value="true">
     <os family="windows"/>
</condition>
<antcall task="windows_task"/>
<antcall task="unix_task"/>

<task name="windows_task if="os_is_windows">
     <blah>
     </blah>
</task>

<task name="unix_task" unless="os_is_windows">
     <blah>
     </blah>
</task>

David Weintraub
david@weintraub.name
qazwart@gmail.com



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


Mime
View raw message