Sophie

Sophie

distrib > Mageia > 2 > i586 > by-pkgid > 16e567b9c4f399396e323ecd14733323 > files > 17

ant-contrib-1.0-0.12.b3.1.mga2.noarch.rpm

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <title>Ant-contrib Tasks: If</title>
  </head>

  <body>
    <h1>If</h1>

    <p>Perform some tasks based on whether a given condition holds
    true or not.</p>

    <p>This task is heavily based on the Condition framework that can
    be found in Ant 1.4 and later, therefore it cannot be used
    inconjunction with versions of Ant prior to 1.4.  Due to numeruos
    bugs in Ant 1.4(.1) that affect this task, we recommend to use Ant
    1.5 or later.</p>

    <h2>Parameters</h2>

    <p>This task doesn't have any attributes, the condition to test is
    specified by a nested element - see the documentation of your
    <code>&lt;condition&gt;</code> task (see <a
    href="http://ant.apache.org/manual/CoreTasks/condition.html">the
    online documentation</a> for example) for a complete list of
    nested elements.</p>

    <p>Just like the <code>&lt;condition&gt;</code> task, only a
    single condition can be specified - you combine them using
    <code>&lt;and&gt;</code> or <code>&lt;or&gt;</code>
    conditions.</p>

    <p>In addition to the condition, you can specify three different
    child elements, <code>&lt;elseif&gt;</code>, <code>&lt;then&gt;</code> and
    <code>&lt;else&gt;</code>.  All three subelements are optional.

    Both <code>&lt;then&gt;</code> and <code>&lt;else&gt;</code> must not be
    used more than once inside the if task.  Both are
    containers for Ant tasks, just like Ant's
    <code>&lt;parallel&gt;</code> and <code>&lt;sequential&gt;</code>
    tasks - in fact they are implemented using the same class as Ant's
    <code>&lt;sequential&gt;</code> task.</p>

    The <code>&lt;elseif&gt;</code> behaves exactly like an <code>&lt;if&gt;</code>
    except that it cannot contain the <code>&lt;else&gt;</code> element
    inside of it.  You may specify as may of these as you like, and the
    order they are specified is the order they are evaluated in.  If the
    condition on the <code>&lt;if&gt;</code> is false, then the first
    <code>&lt;elseif&gt;</code> who's conditional evaluates to true
    will be executed.  The <code>&lt;else&gt;</code> will be executed
    only if the <code>&lt;if&gt;</code> and all <code>&lt;elseif&gt;</code>
    conditions are false.

    <h2>Example</h2>

<pre><code>
&lt;if&gt;
 &lt;equals arg1=&quot;${foo}&quot; arg2=&quot;bar&quot; /&gt;
 &lt;then&gt;
   &lt;echo message=&quot;The value of property foo is bar&quot; /&gt;
 &lt;/then&gt;
 &lt;else&gt;
   &lt;echo message=&quot;The value of property foo is not bar&quot; /&gt;
 &lt;/else&gt;
&lt;/if&gt;
</code></pre>

<pre><code>
&lt;if&gt;
 &lt;equals arg1=&quot;${foo}&quot; arg2=&quot;bar&quot; /&gt;
 &lt;then&gt;
   &lt;echo message=&quot;The value of property foo is 'bar'&quot; /&gt;
 &lt;/then&gt;

 &lt;elseif&gt;
  &lt;equals arg1=&quot;${foo}&quot; arg2=&quot;foo&quot; /&gt;
  &lt;then&gt;
   &lt;echo message=&quot;The value of property foo is 'foo'&quot; /&gt;
  &lt;/then&gt;
 &lt;/elseif&gt;


 &lt;else&gt;
   &lt;echo message=&quot;The value of property foo is not 'foo' or 'bar'&quot; /&gt;
 &lt;/else&gt;
&lt;/if&gt;
</code></pre>

    <hr>
    <p align="center">Copyright &copy; 2002-2003 Ant-Contrib Project. All
    rights Reserved.</p>

  </body>
</html>