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.

available.html 5.9 KiB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  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>Available Task</title>
  20. </head>
  21. <body>
  22. <h2 id="available">Available</h2>
  23. <h3>Description</h3>
  24. <p>Sets a property if a resource is available at runtime. This resource can be a file, a directory,
  25. a class in the classpath, or a JVM system resource.</p>
  26. <p>If the resource is present, 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>Normally, this task is used to set properties that are useful to avoid target execution depending
  30. on system parameters.</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>classname</td>
  50. <td>The class to look for in the classpath.</td>
  51. <td rowspan="3">Exactly one of the three</td>
  52. </tr>
  53. <tr>
  54. <td>file</td>
  55. <td class="left">The file to look for.</td>
  56. </tr>
  57. <tr>
  58. <td>resource</td>
  59. <td class="left">The resource to look for in the JVM.</td>
  60. </tr>
  61. <tr>
  62. <td>classpath</td>
  63. <td>The classpath to use when looking up <var>classname</var> or <var>resource</var>.</td>
  64. <td>No</td>
  65. </tr>
  66. <tr>
  67. <td>filepath</td>
  68. <td>The path to use when looking up <var>file</var>.</td>
  69. <td>No</td>
  70. </tr>
  71. <tr>
  72. <td>classpathref</td>
  73. <td>The classpath to use, given as a <a href="../using.html#references">reference</a> to a path
  74. defined elsewhere.</td>
  75. <td>No</td>
  76. </tr>
  77. <tr>
  78. <td>type</td>
  79. <td>The type of <var>file</var> to look for, either a directory (<var>type</var>=<q>dir</q>) or
  80. a file (<var>type</var>=<q>file</q>). If not set, the property will be set if the name specified
  81. in the <var>file</var> attribute exists as either a file or a directory.</td>
  82. <td>No</td>
  83. </tr>
  84. <tr>
  85. <td>ignoresystemclasses</td>
  86. <td>Ignore Ant's runtime classes, using only the specified classpath. Only affects
  87. the <var>classname</var> attribute.</td>
  88. <td>No; defaults to <q>false</q></td>
  89. </tr>
  90. <tr>
  91. <td>searchparents</td>
  92. <td>This contains the behaviour of the <q>file</q> <var>type</var>. If <q>true</q>, the task
  93. will, when searching for a file, search not only the directories specified but will also search
  94. the parent directories of those specified. If <q>false</q>, only the directories specified will
  95. be searched. <em>Since Ant 1.7</em></td>
  96. <td>No; defaults to <q>false</q></td>
  97. </tr>
  98. </table>
  99. <h3>Parameters specified as nested elements</h3>
  100. <h4>classpath</h4>
  101. <p><code>Available</code>'s <code>classpath</code> attribute is
  102. a <a href="../using.html#path">path-like structure</a> and can also be set via a nested
  103. <code>&lt;classpath&gt;</code> element.</p>
  104. <h4>filepath</h4>
  105. <p><code>Available</code>'s <code>filepath</code> attribute is
  106. a <a href="../using.html#path">path-like structure</a> and can also be set via a
  107. nested <code>&lt;filepath&gt;</code> element.</p>
  108. <h3>Examples</h3>
  109. <pre>&lt;available classname=&quot;org.whatever.Myclass&quot; property=&quot;Myclass.present&quot;/&gt;</pre>
  110. <p>sets the <code>Myclass.present</code> property to the value <q>true</q> if the
  111. class <code>org.whatever.Myclass</code> is found in Ant's classpath.</p>
  112. <pre>
  113. &lt;property name=&quot;jaxp.jar&quot; value=&quot;./lib/jaxp11/jaxp.jar&quot;/&gt;
  114. &lt;available file=&quot;${jaxp.jar}&quot; property=&quot;jaxp.jar.present&quot;/&gt;</pre>
  115. <p>sets the <code>jaxp.jar.present</code> property to the value <q>true</q> if the
  116. file <samp>./lib/jaxp11/jaxp.jar</samp> is found.</p>
  117. <pre>
  118. &lt;available file=&quot;/usr/local/lib&quot; type=&quot;dir&quot;
  119. property=&quot;local.lib.present&quot;/&gt;</pre>
  120. <p>sets the <code>local.lib.present</code> property to the value <q>true</q> if the
  121. directory <samp>/usr/local/lib</samp> is found.</p>
  122. <pre>
  123. ...in project ...
  124. &lt;property name=&quot;jaxp.jar&quot; value=&quot;./lib/jaxp11/jaxp.jar&quot;/&gt;
  125. &lt;path id=&quot;jaxp&quot; location=&quot;${jaxp.jar}&quot;/&gt;
  126. ...in target ...
  127. &lt;available classname=&quot;javax.xml.transform.Transformer&quot;
  128. classpathref=&quot;jaxp&quot; property=&quot;jaxp11.present&quot;/&gt;</pre>
  129. <p>sets the <code>jaxp11.present</code> property to the value <q>true</q> if the
  130. class <code>javax.xml.transform.Transformer</code> is found in the classpath referenced
  131. by <samp>jaxp</samp> (in this case, <samp>./lib/jaxp11/jaxp.jar</samp>).
  132. </p>
  133. <pre>
  134. &lt;available property=&quot;have.extras&quot; resource=&quot;extratasks.properties&quot;&gt;
  135. &lt;classpath&gt;
  136. &lt;pathelement location=&quot;/usr/local/ant/extra.jar&quot;/&gt;
  137. &lt;/classpath&gt;
  138. &lt;/available&gt;</pre>
  139. <p>sets the <code>have.extras</code> property to the value <q>true</q> if the resource
  140. file <samp>extratasks.properties</samp> is found.
  141. </p>
  142. </body>
  143. </html>