1 | <html>
|
---|
2 |
|
---|
3 | <head>
|
---|
4 | <meta http-equiv="Content-Language" content="en-us">
|
---|
5 | <title>Conditions Task</title>
|
---|
6 | <link rel="stylesheet" type="text/css" href="../stylesheets/antmanual.css">
|
---|
7 | </head>
|
---|
8 |
|
---|
9 | <body>
|
---|
10 |
|
---|
11 | <h2><a name="Conditions">Conditions</a></h2>
|
---|
12 | <p>Conditions are nested elements of the
|
---|
13 | <a href="condition.html"><code><condition></code></a> and
|
---|
14 | <a href="waitfor.html"><code><waitfor></code></a> tasks.
|
---|
15 | There are core conditions and custom conditions. Custom
|
---|
16 | conditions are described in
|
---|
17 | <a href="../CoreTypes/custom-programming.html#customconditions">
|
---|
18 | Custom Conditions</a>.
|
---|
19 | Core Conditions are described below.
|
---|
20 | </p>
|
---|
21 | <a name="coreconditions"></a><h3>Core Conditions</h3>
|
---|
22 |
|
---|
23 | <p>These are the nested elements that can be used as conditions in the
|
---|
24 | <a href="condition.html"><code><condition></code></a> and
|
---|
25 | <a href="waitfor.html"><code><waitfor></code></a> tasks.</p>
|
---|
26 |
|
---|
27 | <h4>not</h4>
|
---|
28 | <p>The <code><not></code> element expects exactly one other
|
---|
29 | condition to be nested into this element, negating the result of the
|
---|
30 | condition. It doesn't have any attributes and accepts all nested
|
---|
31 | elements of the condition task as nested elements as well.</p>
|
---|
32 |
|
---|
33 | <h4>and</h4> <p>
|
---|
34 | The <code><and></code> element doesn't have any attributes and
|
---|
35 | accepts an arbitrary number of conditions as nested elements - all
|
---|
36 | nested elements of the condition task are supported. This condition
|
---|
37 | is true if all of its contained conditions are, conditions will be
|
---|
38 | evaluated in the order they have been specified in the build file.</p>
|
---|
39 | <p>The <code><and></code> condition has the same shortcut
|
---|
40 | semantics as the Java && operator, as soon as one of the
|
---|
41 | nested conditions is false, no other condition will be evaluated.</p>
|
---|
42 |
|
---|
43 | <h4>or</h4> <p>
|
---|
44 | The <code><or></code> element doesn't have any attributes and
|
---|
45 | accepts an arbitrary number of conditions as nested elements - all
|
---|
46 | nested elements of the condition task are supported. This condition
|
---|
47 | is true if at least one of its contained conditions is, conditions
|
---|
48 | will be evaluated in the order they have been specified in the build
|
---|
49 | file.</p> <p>The <code><or></code> condition has the same
|
---|
50 | shortcut semantics as the Java || operator, as soon as one of the
|
---|
51 | nested conditions is true, no other condition will be evaluated.</p>
|
---|
52 |
|
---|
53 | <h4>available</h4>
|
---|
54 | <p>This condition is identical to the <a
|
---|
55 | href="available.html">Available</a> task, all attributes and nested
|
---|
56 | elements of that task are supported, the property and value attributes
|
---|
57 | are redundant and will be ignored.</p>
|
---|
58 |
|
---|
59 | <h4>uptodate</h4>
|
---|
60 | <p>This condition is identical to the <a
|
---|
61 | href="uptodate.html">Uptodate</a> task, all attributes and nested
|
---|
62 | elements of that task are supported, the property and value attributes
|
---|
63 | are redundant and will be ignored.</p>
|
---|
64 |
|
---|
65 | <h4>os</h4>
|
---|
66 | <p>Test whether the current operating system is of a given type. Each
|
---|
67 | defined attribute is tested and the result is true only if <i>all</i>
|
---|
68 | the tests succeed.
|
---|
69 | </p>
|
---|
70 | <table border="1" cellpadding="2" cellspacing="0">
|
---|
71 | <tr>
|
---|
72 | <td valign="top"><b>Attribute</b></td>
|
---|
73 | <td valign="top"><b>Description</b></td>
|
---|
74 | <td align="center" valign="top"><b>Required</b></td>
|
---|
75 | </tr>
|
---|
76 | <tr>
|
---|
77 | <td valign="top">family</td>
|
---|
78 | <td valign="top">The name of the operating system family to expect.</td>
|
---|
79 | <td valign="top" align="center">No</td>
|
---|
80 | </tr>
|
---|
81 | <tr>
|
---|
82 | <td valign="top">name</td>
|
---|
83 | <td valign="top">The name of the operating system to expect.</td>
|
---|
84 | <td valign="top" align="center">No</td>
|
---|
85 | </tr>
|
---|
86 | <tr>
|
---|
87 | <td valign="top">arch</td>
|
---|
88 | <td valign="top">The architecture of the operating system to expect.</td>
|
---|
89 | <td valign="top" align="center">No</td>
|
---|
90 | </tr>
|
---|
91 | <tr>
|
---|
92 | <td valign="top">version</td>
|
---|
93 | <td valign="top">The version of the operating system to expect.</td>
|
---|
94 | <td valign="top" align="center">No</td>
|
---|
95 | </tr>
|
---|
96 | </table>
|
---|
97 | <p>Supported values for the family attribute are:
|
---|
98 | <ul>
|
---|
99 | <li>windows (for all versions of Microsoft Windows)</li>
|
---|
100 | <li>dos (for all Microsoft DOS based operating systems including
|
---|
101 | Microsoft Windows and OS/2)</li>
|
---|
102 | <li>mac (for all Apple Macintosh systems)</li>
|
---|
103 | <li>unix (for all Unix and Unix-like operating systems)</li>
|
---|
104 | <li>netware (for Novell NetWare)</li>
|
---|
105 | <li>os/2 (for OS/2)</li>
|
---|
106 | <li>tandem (for HP's NonStop Kernel - formerly Tandem)</li>
|
---|
107 | <li>win9x for Microsoft Windows 95 and 98</li>
|
---|
108 | <li>z/os for z/OS and OS/390</li>
|
---|
109 | <li>os/400 for OS/400</li>
|
---|
110 | <li>openvms for OpenVMS</li>
|
---|
111 | </ul>
|
---|
112 |
|
---|
113 | <h4>equals</h4>
|
---|
114 | <p>Tests whether the two given Strings are identical</p>
|
---|
115 | <table border="1" cellpadding="2" cellspacing="0">
|
---|
116 | <tr>
|
---|
117 | <td valign="top"><b>Attribute</b></td>
|
---|
118 | <td valign="top"><b>Description</b></td>
|
---|
119 | <td align="center" valign="top"><b>Required</b></td>
|
---|
120 | </tr>
|
---|
121 | <tr>
|
---|
122 | <td valign="top">arg1</td>
|
---|
123 | <td valign="top">First string to test.</td>
|
---|
124 | <td valign="top" align="center">Yes</td>
|
---|
125 | </tr>
|
---|
126 | <tr>
|
---|
127 | <td valign="top">arg2</td>
|
---|
128 | <td valign="top">Second string to test.</td>
|
---|
129 | <td valign="top" align="center">Yes</td>
|
---|
130 | </tr>
|
---|
131 | <tr>
|
---|
132 | <td valign="top">casesensitive</td>
|
---|
133 | <td valign="top">Perform a case sensitive comparision. Default is
|
---|
134 | true.</td>
|
---|
135 | <td valign="top" align="center">No</td>
|
---|
136 | </tr>
|
---|
137 | <tr>
|
---|
138 | <td valign="top">trim</td>
|
---|
139 | <td valign="top">Trim whitespace from arguments before comparing
|
---|
140 | them. Default is false.</td>
|
---|
141 | <td valign="top" align="center">No</td>
|
---|
142 | </tr>
|
---|
143 | </table>
|
---|
144 |
|
---|
145 | <h4>isset</h4>
|
---|
146 | <p>Test whether a given property has been set in this project.</p>
|
---|
147 | <table border="1" cellpadding="2" cellspacing="0">
|
---|
148 | <tr>
|
---|
149 | <td valign="top"><b>Attribute</b></td>
|
---|
150 | <td valign="top"><b>Description</b></td>
|
---|
151 | <td align="center" valign="top"><b>Required</b></td>
|
---|
152 | </tr>
|
---|
153 | <tr>
|
---|
154 | <td valign="top">property</td>
|
---|
155 | <td valign="top">The name of the property to test.</td>
|
---|
156 | <td valign="top" align="center">Yes</td>
|
---|
157 | </tr>
|
---|
158 | </table>
|
---|
159 |
|
---|
160 | <h4>checksum</h4>
|
---|
161 | <p>This condition is identical to the <a href="checksum.html">Checksum</a>
|
---|
162 | task, all attributes and nested elements of that task are supported,
|
---|
163 | the property and overwrite attributes are redundant and will be
|
---|
164 | ignored.</p>
|
---|
165 |
|
---|
166 | <h4>http</h4>
|
---|
167 | <p>The <code>http</code> condition checks for a valid response from a
|
---|
168 | web server of the specified url. By default, HTTP responses errors
|
---|
169 | of 400 or greater are viewed as invalid.</p>
|
---|
170 | <table border="1" cellpadding="2" cellspacing="0">
|
---|
171 | <tr>
|
---|
172 | <td width="12%" valign="top"><b>Attribute</b></td>
|
---|
173 | <td width="78%" valign="top"><b>Description</b></td>
|
---|
174 | <td width="10%" valign="top"><b>Required</b></td>
|
---|
175 | </tr>
|
---|
176 | <tr>
|
---|
177 | <td valign="top">url</td>
|
---|
178 | <td valign="top">The full URL of the page to request. The web server must
|
---|
179 | return a status code below the value of <tt>errorsBeginAt</tt></td>
|
---|
180 | <td align="center">Yes.</td>
|
---|
181 | </tr>
|
---|
182 | <tr>
|
---|
183 | <td valign="top">errorsBeginAt</td>
|
---|
184 | <td valign="top">The lowest HTTP response code that signals an error;
|
---|
185 | by default '400'; server errors, not-authorized, not-found and the like
|
---|
186 | are detected</td>
|
---|
187 | <td align="center">No</td>
|
---|
188 | </tr>
|
---|
189 | </table>
|
---|
190 |
|
---|
191 | <h4>socket</h4>
|
---|
192 | <p>The <code>socket</code> condition checks for the existence of a
|
---|
193 | TCP/IP listener at the specified host and port.</p>
|
---|
194 | <table border="1" cellpadding="2" cellspacing="0">
|
---|
195 | <tr>
|
---|
196 | <td width="12%" valign="top"><b>Attribute</b></td>
|
---|
197 | <td width="78%" valign="top"><b>Description</b></td>
|
---|
198 | <td width="10%" valign="top"><b>Required</b></td>
|
---|
199 | </tr>
|
---|
200 | <tr>
|
---|
201 | <td valign="top">server</td>
|
---|
202 | <td valign="top">The DNS name or IP address of the server.</td>
|
---|
203 | <td align="center">Yes.</td>
|
---|
204 | </tr>
|
---|
205 | <tr>
|
---|
206 | <td valign="top">port</td>
|
---|
207 | <td valign="top">The port number to connect to.</td>
|
---|
208 | <td align="center">Yes.</td>
|
---|
209 | </tr>
|
---|
210 | </table>
|
---|
211 |
|
---|
212 | <h4>filesmatch</h4>
|
---|
213 | <p>Test two files for matching. Nonexistence of either file results in "false".
|
---|
214 | This test does a byte for byte comparision, so test time scales with
|
---|
215 | byte size. NB: if the files are different sizes , one of them is missing
|
---|
216 | or the filenames match the answer is so obvious the detailed test is omitted.
|
---|
217 |
|
---|
218 |
|
---|
219 | </p>
|
---|
220 | <table border="1" cellpadding="2" cellspacing="0">
|
---|
221 | <tr>
|
---|
222 | <td width="12%" valign="top"><b>Attribute</b></td>
|
---|
223 | <td width="78%" valign="top"><b>Description</b></td>
|
---|
224 | <td width="10%" valign="top"><b>Required</b></td>
|
---|
225 | </tr>
|
---|
226 | <tr>
|
---|
227 | <td valign="top">file1</td>
|
---|
228 | <td valign="top">First file to test</td>
|
---|
229 | <td align="center">Yes.</td>
|
---|
230 | </tr>
|
---|
231 | <tr>
|
---|
232 | <td valign="top">file2</td>
|
---|
233 | <td valign="top">Second file to test</td>
|
---|
234 | <td align="center">Yes.</td>
|
---|
235 | </tr>
|
---|
236 | </table>
|
---|
237 |
|
---|
238 | <h4>contains</h4>
|
---|
239 | <p>Tests whether a string contains another one.</p>
|
---|
240 | <table border="1" cellpadding="2" cellspacing="0">
|
---|
241 | <tr>
|
---|
242 | <td valign="top"><b>Attribute</b></td>
|
---|
243 | <td valign="top"><b>Description</b></td>
|
---|
244 | <td align="center" valign="top"><b>Required</b></td>
|
---|
245 | </tr>
|
---|
246 | <tr>
|
---|
247 | <td valign="top">string</td>
|
---|
248 | <td valign="top">The string to search in.</td>
|
---|
249 | <td valign="top" align="center">Yes</td>
|
---|
250 | </tr>
|
---|
251 | <tr>
|
---|
252 | <td valign="top">substring</td>
|
---|
253 | <td valign="top">The string to search for.</td>
|
---|
254 | <td valign="top" align="center">Yes</td>
|
---|
255 | </tr>
|
---|
256 | <tr>
|
---|
257 | <td valign="top">casesensitive</td>
|
---|
258 | <td valign="top">Perform a case sensitive comparision. Default is
|
---|
259 | true.</td>
|
---|
260 | <td valign="top" align="center">No</td>
|
---|
261 | </tr>
|
---|
262 | </table>
|
---|
263 |
|
---|
264 | <h4>istrue</h4>
|
---|
265 | <p>Tests whether a string equals any of the ant definitions of true,
|
---|
266 | that is "true","yes", or "on"</p>
|
---|
267 | <table border="1" cellpadding="2" cellspacing="0">
|
---|
268 | <tr>
|
---|
269 | <td valign="top"><b>Attribute</b></td>
|
---|
270 | <td valign="top"><b>Description</b></td>
|
---|
271 | <td align="center" valign="top"><b>Required</b></td>
|
---|
272 | </tr>
|
---|
273 | <tr>
|
---|
274 | <td valign="top">value</td>
|
---|
275 | <td valign="top">value to test</td>
|
---|
276 | <td valign="top" align="center">Yes</td>
|
---|
277 | </tr>
|
---|
278 | </table>
|
---|
279 | <pre>
|
---|
280 | <istrue value="${someproperty}"/>
|
---|
281 | <istrue value="false"/>
|
---|
282 | </pre>
|
---|
283 |
|
---|
284 | <h4>isfalse</h4>
|
---|
285 | <p>Tests whether a string is not true, the negation of <istrue>
|
---|
286 | </p>
|
---|
287 | <table border="1" cellpadding="2" cellspacing="0">
|
---|
288 | <tr>
|
---|
289 | <td valign="top"><b>Attribute</b></td>
|
---|
290 | <td valign="top"><b>Description</b></td>
|
---|
291 | <td align="center" valign="top"><b>Required</b></td>
|
---|
292 | </tr>
|
---|
293 | <tr>
|
---|
294 | <td valign="top">value</td>
|
---|
295 | <td valign="top">value to test</td>
|
---|
296 | <td valign="top" align="center">Yes</td>
|
---|
297 | </tr>
|
---|
298 | </table>
|
---|
299 | <pre>
|
---|
300 | <isfalse value="${someproperty}"/>
|
---|
301 | <isfalse value="false"/>
|
---|
302 | </pre>
|
---|
303 |
|
---|
304 | <h4>isreference</h4>
|
---|
305 |
|
---|
306 | <p>Test whether a given reference has been defined in this project and
|
---|
307 | - optionally - is of an expected type.</p>
|
---|
308 |
|
---|
309 | <p>This condition has been added in Apache Ant 1.6.</p>
|
---|
310 |
|
---|
311 | <table border="1" cellpadding="2" cellspacing="0">
|
---|
312 | <tr>
|
---|
313 | <td valign="top"><b>Attribute</b></td>
|
---|
314 | <td valign="top"><b>Description</b></td>
|
---|
315 | <td align="center" valign="top"><b>Required</b></td>
|
---|
316 | </tr>
|
---|
317 | <tr>
|
---|
318 | <td valign="top">refid</td>
|
---|
319 | <td valign="top">The id of the reference to test.</td>
|
---|
320 | <td valign="top" align="center">Yes</td>
|
---|
321 | </tr>
|
---|
322 | <tr>
|
---|
323 | <td valign="top">type</td>
|
---|
324 | <td valign="top">Name of the data type or task this reference is
|
---|
325 | expected to be.</td>
|
---|
326 | <td valign="top" align="center">No</td>
|
---|
327 | </tr>
|
---|
328 | </table>
|
---|
329 |
|
---|
330 | <hr>
|
---|
331 | <p align="center">Copyright © 2001-2004 The Apache Software
|
---|
332 | Foundation. All rights Reserved.</p>
|
---|
333 |
|
---|
334 | </body>
|
---|
335 | </html>
|
---|