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 7.3 KiB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218
  1. <html>
  2. <head>
  3. <meta http-equiv="Content-Language" content="en-us">
  4. <title>Apache Ant User Manual</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. </ul>
  86. <h4>equals</h4>
  87. <p>Tests whether the two given Strings are identical</p>
  88. <table border="1" cellpadding="2" cellspacing="0">
  89. <tr>
  90. <td valign="top"><b>Attribute</b></td>
  91. <td valign="top"><b>Description</b></td>
  92. <td align="center" valign="top"><b>Required</b></td>
  93. </tr>
  94. <tr>
  95. <td valign="top">arg1</td>
  96. <td valign="top">First string to test.</td>
  97. <td valign="top" align="center">Yes</td>
  98. </tr>
  99. <tr>
  100. <td valign="top">arg2</td>
  101. <td valign="top">Second string to test.</td>
  102. <td valign="top" align="center">Yes</td>
  103. </tr>
  104. <tr>
  105. <td valign="top">casesensitive</td>
  106. <td valign="top">Perform a case sensitive comparision. Default is
  107. true.</td>
  108. <td valign="top" align="center">No</td>
  109. </tr>
  110. <tr>
  111. <td valign="top">trim</td>
  112. <td valign="top">Trim whitespace from arguments before comparing
  113. them. Default is false.</td>
  114. <td valign="top" align="center">No</td>
  115. </tr>
  116. </table>
  117. <h4>isset</h4>
  118. <p>Test whether a given property has been set in this project.</p>
  119. <table border="1" cellpadding="2" cellspacing="0">
  120. <tr>
  121. <td valign="top"><b>Attribute</b></td>
  122. <td valign="top"><b>Description</b></td>
  123. <td align="center" valign="top"><b>Required</b></td>
  124. </tr>
  125. <tr>
  126. <td valign="top">property</td>
  127. <td valign="top">The name of the property to test.</td>
  128. <td valign="top" align="center">Yes</td>
  129. </tr>
  130. </table>
  131. <h4>checksum</h4>
  132. <p>This condition is identical to the <a href="checksum.html">Checksum</a>
  133. task, all attributes and nested elements of that task are supported,
  134. the property and overwrite attributes are redundant and will be
  135. ignored.</p>
  136. <h4>http</h4>
  137. <p>The <code>http</code> condition checks for a valid response from a
  138. web server of the specified url.</p>
  139. <table border="1" cellpadding="2" cellspacing="0">
  140. <tr>
  141. <td width="12%" valign="top"><b>Attribute</b></td>
  142. <td width="78%" valign="top"><b>Description</b></td>
  143. <td width="10%" valign="top"><b>Required</b></td>
  144. </tr>
  145. <tr>
  146. <td valign="top">url</td>
  147. <td valign="top">The full URL of the page to request. The web server must
  148. return a status code of &lt;500..</td>
  149. <td align="center">Yes.</td>
  150. </tr>
  151. </table>
  152. <h4>socket</h4>
  153. <p>The <code>socket</code> condition checks for the existence of a
  154. TCP/IP listener at the specified host and port.</p>
  155. <table border="1" cellpadding="2" cellspacing="0">
  156. <tr>
  157. <td width="12%" valign="top"><b>Attribute</b></td>
  158. <td width="78%" valign="top"><b>Description</b></td>
  159. <td width="10%" valign="top"><b>Required</b></td>
  160. </tr>
  161. <tr>
  162. <td valign="top">server</td>
  163. <td valign="top">The DNS name or IP address of the server.</td>
  164. <td align="center">Yes.</td>
  165. </tr>
  166. <tr>
  167. <td valign="top">port</td>
  168. <td valign="top">The port number to connect to.</td>
  169. <td align="center">Yes.</td>
  170. </tr>
  171. </table>
  172. <h4>filesmatch</h4>
  173. <p>Test two files for matching. Both files must exist first.
  174. This test does a byte for byte comparision, so test time scales with
  175. byte size. NB: if the files are different sizes or the filenames match
  176. the slower test is shortcutted.
  177. </p>
  178. <table border="1" cellpadding="2" cellspacing="0">
  179. <tr>
  180. <td width="12%" valign="top"><b>Attribute</b></td>
  181. <td width="78%" valign="top"><b>Description</b></td>
  182. <td width="10%" valign="top"><b>Required</b></td>
  183. </tr>
  184. <tr>
  185. <td valign="top">file1</td>
  186. <td valign="top">First file to test</td>
  187. <td align="center">Yes.</td>
  188. </tr>
  189. <tr>
  190. <td valign="top">file2</td>
  191. <td valign="top">Second file to test</td>
  192. <td align="center">Yes.</td>
  193. </tr>
  194. </table>
  195. <hr>
  196. <p align="center">Copyright &copy; 2001-2002 Apache Software
  197. Foundation. All rights Reserved.</p>
  198. </body>
  199. </html>