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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. <!--
  2. Licensed to the Apache Software Foundation (ASF) under one or more
  3. contributor license agreements. See the NOTICE file distributed with
  4. this work for additional information regarding copyright ownership.
  5. The ASF licenses this file to You under the Apache License, Version 2.0
  6. (the "License"); you may not use this file except in compliance with
  7. the License. You may obtain a copy of the License at
  8. http://www.apache.org/licenses/LICENSE-2.0
  9. Unless required by applicable law or agreed to in writing, software
  10. distributed under the License is distributed on an "AS IS" BASIS,
  11. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. See the License for the specific language governing permissions and
  13. limitations under the License.
  14. -->
  15. <html>
  16. <head>
  17. <meta http-equiv="Content-Language" content="en-us">
  18. <link rel="stylesheet" type="text/css" href="../stylesheets/style.css">
  19. <title>Condition Task</title>
  20. </head>
  21. <body>
  22. <h2><a name="Condition">Condition</a></h2>
  23. <h3>Description</h3>
  24. <p>Sets a property if a certain condition holds true - this is a
  25. generalization of <a href="available.html">Available</a> and <a
  26. href="uptodate.html">Uptodate</a>.</p>
  27. <p>If the condition holds true, the property value is set to true by
  28. default; otherwise, the property is not set. You can set the value to
  29. something other than the default by specifying the <code>value</code>
  30. attribute.</p>
  31. <p>Conditions are specified as <a href="#nested">nested elements</a>,
  32. you must specify exactly one condition.</p>
  33. <h3>Parameters</h3>
  34. <table border="1" cellpadding="2" cellspacing="0">
  35. <tr>
  36. <td valign="top"><b>Attribute</b></td>
  37. <td valign="top"><b>Description</b></td>
  38. <td align="center" valign="top"><b>Required</b></td>
  39. </tr>
  40. <tr>
  41. <td valign="top">property</td>
  42. <td valign="top">The name of the property to set.</td>
  43. <td valign="top" align="center">Yes</td>
  44. </tr>
  45. <tr>
  46. <td valign="top">value</td>
  47. <td valign="top">The value to set the property to. Defaults to
  48. &quot;true&quot;.</td>
  49. <td valign="top" align="center">No</td>
  50. </tr>
  51. <tr>
  52. <td valign="top">else</td>
  53. <td valign="top">The value to set the property to if the condition
  54. evaluates to <i>false</i>. By default the property will remain unset.
  55. <em>Since Ant 1.6.3</em>
  56. </td>
  57. <td valign="top" align="center">No</td>
  58. </tr>
  59. </table>
  60. <h3><a name="nested">Parameters specified as nested elements</a></h3>
  61. <p>All conditions to test are specified as nested elements, for a
  62. complete list see <a href="conditions.html">here</a>.</p>
  63. <h3>Examples</h3>
  64. <pre>
  65. &lt;condition property=&quot;javamail.complete&quot;&gt;
  66. &lt;and&gt;
  67. &lt;available classname=&quot;javax.activation.DataHandler&quot;/&gt;
  68. &lt;available classname=&quot;javax.mail.Transport&quot;/&gt;
  69. &lt;/and&gt;
  70. &lt;/condition&gt;
  71. </pre>
  72. <p>sets the property <code>javamail.complete</code> if both the
  73. JavaBeans Activation Framework and JavaMail are available in the
  74. classpath.</p>
  75. <pre>
  76. &lt;condition property=&quot;isMacOsButNotMacOsX&quot;&gt;
  77. &lt;and&gt;
  78. &lt;os family=&quot;mac&quot;/&gt;
  79. &lt;not&gt;
  80. &lt;os family=&quot;unix&quot;/&gt;
  81. &lt;/not&gt;
  82. &lt;/and&gt;
  83. &lt;/condition&gt;
  84. </pre>
  85. <p>sets the property <code>isMacOsButNotMacOsX</code> if the current
  86. operating system is MacOS, but not MacOS X - which Ant considers to be
  87. in the Unix family as well.</p>
  88. <pre>
  89. &lt;condition property=&quot;isSunOSonSparc&quot;&gt;
  90. &lt;os name=&quot;SunOS&quot; arch=&quot;sparc&quot;/&gt;
  91. &lt;/condition&gt;
  92. </pre>
  93. <p>sets the property <code>isSunOSonSparc</code> if the current
  94. operating system is SunOS and if it is running on a sparc architecture.</p>
  95. </body>
  96. </html>