ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Stefan Bodewig <>
Subject Re: conditional logic and making it nicely extensible
Date Tue, 11 Sep 2001 13:20:24 GMT
On Tue, 11 Sep 2001, Ken Wood <> wrote:

> Since some of us are not good at reading source code
> and deducing what the xml should look like, could
> you please provide an example or two???

Sure 8-)

<if> supports three types of nested child elements:

(1) Exactly one condition - the same way <condition> has exactly one
condition child, i.e. one of <not>, <and>, <or>, <available>,
<uptodate>, <os>, <equals>.

(2) Zero or one <then> element.

(3) Zero or one <else> element.

<then> and <else> can themselves contain an arbitrary number of tasks.
If the condition is true the tasks in the <then> element (if present)
will be executed, otherwise the tasks in the <else> element (if
present) will be executed.

<project default="if">
  <target name="if">
        <equals arg1="${foo}" arg2="bar" />
        <equals arg1="${foo}" arg2="baz" />
        <echo message="foo is boring" />
        <echo message="foo is not that boring" />

would be one example, where values of bar and baz for the property foo
would be considered boring.

<condition property="foo" value="bar">

would be a shortcut for

    <property name="foo" value="bar">

(just that <condition> will override existing properties).


View raw message