ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "David Weintraub" <>
Subject Re: conditional statements
Date Thu, 14 Feb 2008 22:07:25 GMT
In standard Ant, you use the <condition> task to set a property, then
you can use <antcall> to call a task.

<task name="if_else_task">
         <istrue value="${x}"/>
    <antcall target="do_if_x_is_true"/>
    <antcall target="do_if_x_is_false"/>

<target name="do_if_x_is_true"
    <echo>X is True!</echo>

<target name="do_if_x_is_false"
   <echo>X is False!</echo>

A little complex, but that's how it's done.

AntContrib (as others have pointed out) has an <if> task:

    <istrue value="${x}"/>
          <echo>X is True!</echo>
         <echo>X is False</echo>

This is simpler, but you must include the ant-contrib-xxx.jar file in
your Ant's classpath, and include a <taskdef> task in your build.xml
file. See the AntContrib website for more information.

On Thu, Feb 14, 2008 at 2:42 PM, jonese <> wrote:
> How would i do something like
>  if x = true{
>   stuff
>  }else{
>   other stuff
>  }
>  in ant? basically i want to see if a property is true and if it is do
>  x instructions, if it's false do y.
>  jonese
>  ---------------------------------------------------------------------
>  To unsubscribe, e-mail:
>  For additional commands, e-mail:

David Weintraub

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

View raw message