You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

conditions.html 10 KiB

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