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.

condition.html 6.2 KiB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181
  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="Condition">Condition</a></h2>
  8. <h3>Description</h3>
  9. <p>Sets a property if a certain condition holds true - this is a
  10. generalization of <a href="available.html">Available</a> and <a
  11. href="uptodate.html">Uptodate</a>.</p>
  12. <p>If the condition holds true, the property value is set to true by
  13. default; otherwise, the property is not set. You can set the value to
  14. something other than the default by specifying the <code>value</code>
  15. attribute.</p>
  16. <p>Conditions are specified as <a href="#nested">nested elements</a>,
  17. you must specify exactly one condition.</p>
  18. <h3>Parameters</h3>
  19. <table border="1" cellpadding="2" cellspacing="0">
  20. <tr>
  21. <td valign="top"><b>Attribute</b></td>
  22. <td valign="top"><b>Description</b></td>
  23. <td align="center" valign="top"><b>Required</b></td>
  24. </tr>
  25. <tr>
  26. <td valign="top">property</td>
  27. <td valign="top">The name of the property to set.</td>
  28. <td valign="top" align="center">Yes</td>
  29. </tr>
  30. <tr>
  31. <td valign="top">value</td>
  32. <td valign="top">The value to set the property to. Defaults to
  33. &quot;true&quot;.</td>
  34. <td valign="top" align="center">No</td>
  35. </tr>
  36. </table>
  37. <h3><a name="nested">Parameters specified as nested elements</a></h3>
  38. <p>All conditions to test are specified as nested elements.</p>
  39. <h4>not</h4>
  40. <p>The <code>&lt;not&gt;</code> element expects exactly one other
  41. condition to be nested into this element, negating the result of the
  42. condition. It doesn't have any attributes and accepts all nested
  43. elements of the condition task as nested elements as well.</p>
  44. <h4>and</h4> <p>
  45. The <code>&lt;and&gt;</code> element doesn't have any attributes and
  46. accepts an arbitrary number of conditions as nested elements - all
  47. nested elements of the condition task are supported. This condition
  48. is true if all of its contained conditions are, conditions will be
  49. evaluated in the order they have been specified in the build file.</p>
  50. <p>The <code>&lt;and&gt;</code> condition has the same shortcut
  51. semantics as the Java &amp;&amp; operator, as soon as one of the
  52. nested conditions is false, no other condition will be evaluated.</p>
  53. <h4>or</h4> <p>
  54. The <code>&lt;or&gt;</code> element doesn't have any attributes and
  55. accepts an arbitrary number of conditions as nested elements - all
  56. nested elements of the condition task are supported. This condition
  57. is true if at least one of its contained conditions is, conditions
  58. will be evaluated in the order they have been specified in the build
  59. file.</p> <p>The <code>&lt;or&gt;</code> condition has the same
  60. shortcut semantics as the Java || operator, as soon as one of the
  61. nested conditions is true, no other condition will be evaluated.</p>
  62. <h4>available</h4>
  63. <p>This condition is identical to the <a
  64. href="available.html">Available</a> task, all attributes and nested
  65. elements of that task are supported, the property and value attributes
  66. are redundant and will be ignored.</p>
  67. <h4>uptodate</h4>
  68. <p>This condition is identical to the <a
  69. href="uptodate.html">Uptodate</a> task, all attributes and nested
  70. elements of that task are supported, the property and value attributes
  71. are redundant and will be ignored.</p>
  72. <h4>os</h4>
  73. <p>Test whether the current operating system is of a given type.</p>
  74. <table border="1" cellpadding="2" cellspacing="0">
  75. <tr>
  76. <td valign="top"><b>Attribute</b></td>
  77. <td valign="top"><b>Description</b></td>
  78. <td align="center" valign="top"><b>Required</b></td>
  79. </tr>
  80. <tr>
  81. <td valign="top">family</td>
  82. <td valign="top">The name of the operating system family to expect.</td>
  83. <td valign="top" align="center">No</td>
  84. </tr>
  85. </table>
  86. <p>Supported values for the family attribute are:
  87. <ul>
  88. <li>windows (for all versions of Microsoft Windows)</li>
  89. <li>dos (for all Microsoft DOS based operating systems including
  90. Microsoft Windows and OS/2)</li>
  91. <li>mac (for all Apple Macintosh systems)</li>
  92. <li>unix (for all Unix and Unix-like operating systems)</li>
  93. <li>netware (for Novell NetWare)</li>
  94. <li>os/2 (for OS/2)</li>
  95. </ul>
  96. <h4>equals</h4>
  97. <p>Tests whether the two given Strings are identical</p>
  98. <table border="1" cellpadding="2" cellspacing="0">
  99. <tr>
  100. <td valign="top"><b>Attribute</b></td>
  101. <td valign="top"><b>Description</b></td>
  102. <td align="center" valign="top"><b>Required</b></td>
  103. </tr>
  104. <tr>
  105. <td valign="top">arg1</td>
  106. <td valign="top">First string to test.</td>
  107. <td valign="top" align="center">Yes</td>
  108. </tr>
  109. <tr>
  110. <td valign="top">arg2</td>
  111. <td valign="top">Second string to test.</td>
  112. <td valign="top" align="center">Yes</td>
  113. </tr>
  114. </table>
  115. <h4>isset</h4>
  116. <p>Test whether a given property has been set in this project.</p>
  117. <table border="1" cellpadding="2" cellspacing="0">
  118. <tr>
  119. <td valign="top"><b>Attribute</b></td>
  120. <td valign="top"><b>Description</b></td>
  121. <td align="center" valign="top"><b>Required</b></td>
  122. </tr>
  123. <tr>
  124. <td valign="top">property</td>
  125. <td valign="top">The name of the property to test.</td>
  126. <td valign="top" align="center">Yes</td>
  127. </tr>
  128. </table>
  129. <h4>checksum</h4>
  130. <p>This condition is identical to the <a
  131. href="checksum.html">Checksum</a> task, all attributes and nested
  132. elements of that task are supported, the property and overwrite
  133. attributes are redundant and will be ignored.</p>
  134. <h3>Examples</h3>
  135. <pre>
  136. &lt;condition property=&quot;javamail.complete&quot;&gt;
  137. &lt;and&gt;
  138. &lt;available classname=&quot;javax.activation.DataHandler&quot; /&gt;
  139. &lt;available classname=&quot;javax.mail.Transport&quot; /&gt;
  140. &lt;/and&gt;
  141. &lt;/condition&gt;
  142. </pre>
  143. <p>sets the property <code>javamail.complete</code> if both the
  144. JavaBeans Activation Framework and JavaMail are available in the
  145. classpath.</p>
  146. <pre>
  147. &lt;condition property=&quot;isMacOsButNotMacOsX&quot;&gt;
  148. &lt;and&gt;
  149. &lt;os family=&quot;mac&quot; />
  150. &lt;not&gt;
  151. &lt;os family=&quot;unix&quot; />
  152. &lt;/not&gt;
  153. &lt;/and&gt;
  154. &lt;/condition&gt;
  155. </pre>
  156. <p>sets the property <code>isMacOsButNotMacOsX</code> if the current
  157. operating system is MacOS, but not MacOS X - which Ant considers to be
  158. in the Unix family as well.</p>
  159. <hr>
  160. <p align="center">Copyright &copy; 2001 Apache Software
  161. Foundation. All rights Reserved.</p>
  162. </body>
  163. </html>