Debian Codegraph @

docs/manual/tasks/if.html

raw symbols SCIP
1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
2 <html>
3 <head>
4 <title>Ant-contrib Tasks: If</title>
5 </head>
6
7 <body>
8 <h1>If</h1>
9
10 <p>Perform some tasks based on whether a given condition holds
11 true or not.</p>
12
13 <p>This task is heavily based on the Condition framework that can
14 be found in Ant 1.4 and later, therefore it cannot be used
15 inconjunction with versions of Ant prior to 1.4. Due to numeruos
16 bugs in Ant 1.4(.1) that affect this task, we recommend to use Ant
17 1.5 or later.</p>
18
19 <h2>Parameters</h2>
20
21 <p>This task doesn't have any attributes, the condition to test is
22 specified by a nested element - see the documentation of your
23 <code>&lt;condition&gt;</code> task (see <a
24 href="http://ant.apache.org/manual/CoreTasks/condition.html">the
25 online documentation</a> for example) for a complete list of
26 nested elements.</p>
27
28 <p>Just like the <code>&lt;condition&gt;</code> task, only a
29 single condition can be specified - you combine them using
30 <code>&lt;and&gt;</code> or <code>&lt;or&gt;</code>
31 conditions.</p>
32
33 <p>In addition to the condition, you can specify three different
34 child elements, <code>&lt;elseif&gt;</code>, <code>&lt;then&gt;</code> and
35 <code>&lt;else&gt;</code>. All three subelements are optional.
36
37 Both <code>&lt;then&gt;</code> and <code>&lt;else&gt;</code> must not be
38 used more than once inside the if task. Both are
39 containers for Ant tasks, just like Ant's
40 <code>&lt;parallel&gt;</code> and <code>&lt;sequential&gt;</code>
41 tasks - in fact they are implemented using the same class as Ant's
42 <code>&lt;sequential&gt;</code> task.</p>
43
44 The <code>&lt;elseif&gt;</code> behaves exactly like an <code>&lt;if&gt;</code>
45 except that it cannot contain the <code>&lt;else&gt;</code> element
46 inside of it. You may specify as may of these as you like, and the
47 order they are specified is the order they are evaluated in. If the
48 condition on the <code>&lt;if&gt;</code> is false, then the first
49 <code>&lt;elseif&gt;</code> who's conditional evaluates to true
50 will be executed. The <code>&lt;else&gt;</code> will be executed
51 only if the <code>&lt;if&gt;</code> and all <code>&lt;elseif&gt;</code>
52 conditions are false.
53
54 <h2>Example</h2>
55
56 <pre><code>
57 &lt;if&gt;
58 &lt;equals arg1=&quot;${foo}&quot; arg2=&quot;bar&quot; /&gt;
59 &lt;then&gt;
60 &lt;echo message=&quot;The value of property foo is bar&quot; /&gt;
61 &lt;/then&gt;
62 &lt;else&gt;
63 &lt;echo message=&quot;The value of property foo is not bar&quot; /&gt;
64 &lt;/else&gt;
65 &lt;/if&gt;
66 </code></pre>
67
68 <pre><code>
69 &lt;if&gt;
70 &lt;equals arg1=&quot;${foo}&quot; arg2=&quot;bar&quot; /&gt;
71 &lt;then&gt;
72 &lt;echo message=&quot;The value of property foo is 'bar'&quot; /&gt;
73 &lt;/then&gt;
74
75 &lt;elseif&gt;
76 &lt;equals arg1=&quot;${foo}&quot; arg2=&quot;foo&quot; /&gt;
77 &lt;then&gt;
78 &lt;echo message=&quot;The value of property foo is 'foo'&quot; /&gt;
79 &lt;/then&gt;
80 &lt;/elseif&gt;
81
82
83 &lt;else&gt;
84 &lt;echo message=&quot;The value of property foo is not 'foo' or 'bar'&quot; /&gt;
85 &lt;/else&gt;
86 &lt;/if&gt;
87 </code></pre>
88
89 <hr>
90 <p align="center">Copyright &copy; 2002-2003 Ant-Contrib Project. All
91 rights Reserved.</p>
92
93 </body>
94 </html>