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.4 KiB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  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 id="condition">Condition</h2>
  23. <h3>Description</h3>
  24. <p>Sets a property if a certain condition holds true&mdash;this is a generalization
  25. of <a href="available.html">Available</a> and <a href="uptodate.html">Uptodate</a>.</p>
  26. <p>If the condition holds true, the property value is set to <q>true</q> by default; otherwise, the
  27. property is not set. You can set the value to something other than the default by specifying
  28. the <var>value</var> attribute.</p>
  29. <p>Conditions are specified as <a href="#nested">nested elements</a>, you must specify exactly one
  30. condition.</p>
  31. <h3>Parameters</h3>
  32. <table class="attr">
  33. <tr>
  34. <th>Attribute</th>
  35. <th>Description</th>
  36. <th>Required</th>
  37. </tr>
  38. <tr>
  39. <td>property</td>
  40. <td>The name of the property to set.</td>
  41. <td>Yes</td>
  42. </tr>
  43. <tr>
  44. <td>value</td>
  45. <td>The value to set the property to.</td>
  46. <td>No; defaults to <q>true</q></td>
  47. </tr>
  48. <tr>
  49. <td>else</td>
  50. <td>The value to set the property to if the condition evaluates to <q>false</q>. <em>Since
  51. Apache Ant 1.6.3</em>
  52. </td>
  53. <td>No; by default the property will remain unset</td>
  54. </tr>
  55. </table>
  56. <h3 id="nested">Parameters specified as nested elements</h3>
  57. <p>All conditions to test are specified as nested elements, for a complete list
  58. see <a href="conditions.html">here</a>.</p>
  59. <h3>Examples</h3>
  60. <pre>
  61. &lt;condition property=&quot;javamail.complete&quot;&gt;
  62. &lt;and&gt;
  63. &lt;available classname=&quot;javax.activation.DataHandler&quot;/&gt;
  64. &lt;available classname=&quot;javax.mail.Transport&quot;/&gt;
  65. &lt;/and&gt;
  66. &lt;/condition&gt;</pre>
  67. <p>sets the property <code>javamail.complete</code> if both the JavaBeans Activation Framework and
  68. JavaMail are available in the classpath.</p>
  69. <pre>
  70. &lt;condition property=&quot;isMacOsButNotMacOsX&quot;&gt;
  71. &lt;and&gt;
  72. &lt;os family=&quot;mac&quot;/&gt;
  73. &lt;not&gt;
  74. &lt;os family=&quot;unix&quot;/&gt;
  75. &lt;/not&gt;
  76. &lt;/and&gt;
  77. &lt;/condition&gt;</pre>
  78. <p>sets the property <code>isMacOsButNotMacOsX</code> if the current operating system is MacOS, but
  79. not MacOS X/macOS&mdash;which Ant considers to be in the Unix family as well.</p>
  80. <pre>
  81. &lt;condition property=&quot;isSunOSonSparc&quot;&gt;
  82. &lt;os name=&quot;SunOS&quot; arch=&quot;sparc&quot;/&gt;
  83. &lt;/condition&gt;</pre>
  84. <p>sets the property <code>isSunOSonSparc</code> if the current operating system is SunOS and if it
  85. is running on a SPARC architecture.</p>
  86. </body>
  87. </html>