blob: e080d220c9e2c6d3ae03a69213c3db9edad94c25 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
|
<!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><condition></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><condition></code> task, only a
single condition can be specified - you combine them using
<code><and></code> or <code><or></code>
conditions.</p>
<p>In addition to the condition, you can specify three different
child elements, <code><elseif></code>, <code><then></code> and
<code><else></code>. All three subelements are optional.
Both <code><then></code> and <code><else></code> must not be
used more than once inside the if task. Both are
containers for Ant tasks, just like Ant's
<code><parallel></code> and <code><sequential></code>
tasks - in fact they are implemented using the same class as Ant's
<code><sequential></code> task.</p>
The <code><elseif></code> behaves exactly like an <code><if></code>
except that it cannot contain the <code><else></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><if></code> is false, then the first
<code><elseif></code> who's conditional evaluates to true
will be executed. The <code><else></code> will be executed
only if the <code><if></code> and all <code><elseif></code>
conditions are false.
<h2>Example</h2>
<pre><code>
<if>
<equals arg1="${foo}" arg2="bar" />
<then>
<echo message="The value of property foo is bar" />
</then>
<else>
<echo message="The value of property foo is not bar" />
</else>
</if>
</code></pre>
<pre><code>
<if>
<equals arg1="${foo}" arg2="bar" />
<then>
<echo message="The value of property foo is 'bar'" />
</then>
<elseif>
<equals arg1="${foo}" arg2="foo" />
<then>
<echo message="The value of property foo is 'foo'" />
</then>
</elseif>
<else>
<echo message="The value of property foo is not 'foo' or 'bar'" />
</else>
</if>
</code></pre>
<hr>
<p align="center">Copyright © 2002-2003 Ant-Contrib Project. All
rights Reserved.</p>
</body>
</html>
|