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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160
  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><a name="available">Available</a></h2>
  23. <h3>Description</h3>
  24. <p>Sets a property if a resource is available at runtime. This resource can be a
  25. file, a directory, a class in the classpath, or a JVM system resource.</p>
  26. <p>If the resource is present, the property value is set to true by
  27. default; otherwise, the property is not set. You can set the value to
  28. something other than the default by specifying the <code>value</code> attribute.</p>
  29. <p>Normally, this task is used to set properties that are useful to avoid target
  30. execution depending on system parameters.</p>
  31. <h3>Parameters</h3>
  32. <table border="1" cellpadding="2" cellspacing="0">
  33. <tr>
  34. <td valign="top"><b>Attribute</b></td>
  35. <td valign="top"><b>Description</b></td>
  36. <td align="center" valign="top"><b>Required</b></td>
  37. </tr>
  38. <tr>
  39. <td valign="top">property</td>
  40. <td valign="top">The name of the property to set.</td>
  41. <td valign="top" align="center">Yes</td>
  42. </tr>
  43. <tr>
  44. <td valign="top">value</td>
  45. <td valign="top">The value to set the property to. Defaults to &quot;true&quot;.</td>
  46. <td valign="top" align="center">No</td>
  47. </tr>
  48. <tr>
  49. <td valign="top">classname</td>
  50. <td valign="top">The class to look for in the classpath.</td>
  51. <td valign="middle" align="center" rowspan="3">Yes</td>
  52. </tr>
  53. <tr>
  54. <td valign="top">file</td>
  55. <td valign="top">The file to look for.</td>
  56. </tr>
  57. <tr>
  58. <td valign="top">resource</td>
  59. <td valign="top">The resource to look for in the JVM.</td>
  60. </tr>
  61. <tr>
  62. <td valign="top">classpath</td>
  63. <td valign="top">The classpath to use when looking up <code>classname</code> or <code>resource</code>.</td>
  64. <td align="center" valign="top">No</td>
  65. </tr>
  66. <tr>
  67. <td valign="top">filepath</td>
  68. <td valign="top">The path to use when looking up <code>file</code>.</td>
  69. <td align="center" valign="top">No</td>
  70. </tr>
  71. <tr>
  72. <td valign="top">classpathref</td>
  73. <td valign="top">The classpath to use, given as a <a href="../using.html#references">reference</a> to a path defined elsewhere.</td>
  74. <td align="center" valign="top">No</td>
  75. </tr>
  76. <tr>
  77. <td valign="top">type</td>
  78. <td valign="top">The type of <code>file</code> to look for, either a directory (<code>type=&quot;dir&quot;</code>) or a file
  79. (<code>type=&quot;file&quot;</code>). If not set, the property will be set if the name specified in the <code>file</code>
  80. attribute exists as either a file or a directory.</td>
  81. <td align="center" valign="top">No</td>
  82. </tr>
  83. <tr>
  84. <td valign="top">ignoresystemclasses</td>
  85. <td valign="top">Ignore Ant's runtime classes, using only the specified
  86. classpath. Only affects the "classname" attribute. Defaults to &quot;false&quot;</td>
  87. <td align="center" valign="top">No</td>
  88. </tr>
  89. <tr>
  90. <td valign="top">searchparents</td>
  91. <td valign="top">This contains the behaviour of the "file" type.
  92. If true, the available task will, when
  93. searching for a file, search not only the directories specified but
  94. will also search the parent directories of those
  95. specified.
  96. If false, only the directories specified will be searched.
  97. Defaults to "false".
  98. <em>Since Ant 1.7</em>
  99. </td>
  100. <td align="center" valign="top">No</td>
  101. </tr>
  102. </table>
  103. <h3>Parameters specified as nested elements</h3>
  104. <h4>classpath</h4>
  105. <p><code>Available</code>'s <code>classpath</code> attribute is a <a
  106. href="../using.html#path">path-like structure</a> and can also be set via a nested
  107. <code>&lt;classpath&gt;</code> element.</p>
  108. <h4>filepath</h4>
  109. <p><code>Available</code>'s <code>filepath</code> attribute is a <a
  110. href="../using.html#path">path-like structure</a> and can also be set via a nested
  111. <code>&lt;filepath&gt;</code> element.</p>
  112. <h3>Examples</h3>
  113. <blockquote><pre>
  114. &lt;available classname=&quot;org.whatever.Myclass&quot; property=&quot;Myclass.present&quot;/&gt;
  115. </pre></blockquote>
  116. <p>sets the <code>Myclass.present</code> property to the value &quot;true&quot;
  117. if the class <code>org.whatever.Myclass</code> is found in Ant's classpath.</p>
  118. <blockquote><pre>
  119. &lt;property name=&quot;jaxp.jar&quot; value=&quot;./lib/jaxp11/jaxp.jar&quot;/&gt;
  120. &lt;available file=&quot;${jaxp.jar}&quot; property=&quot;jaxp.jar.present&quot;/&gt;
  121. </pre></blockquote>
  122. <p>sets the <code>jaxp.jar.present</code> property to the value &quot;true&quot;
  123. if the file <code>./lib/jaxp11/jaxp.jar</code> is found.</p>
  124. <blockquote><pre>
  125. &lt;available file=&quot;/usr/local/lib&quot; type=&quot;dir&quot;
  126. property=&quot;local.lib.present&quot;/&gt;
  127. </pre></blockquote>
  128. <p>sets the <code>local.lib.present</code> property to the value &quot;true&quot;
  129. if the directory <code>/usr/local/lib</code> is found.</p>
  130. <blockquote><pre>
  131. ...in project ...
  132. &lt;property name=&quot;jaxp.jar&quot; value=&quot;./lib/jaxp11/jaxp.jar&quot;/&gt;
  133. &lt;path id=&quot;jaxp&quot; location=&quot;${jaxp.jar}&quot;/&gt;
  134. ...in target ...
  135. &lt;available classname=&quot;javax.xml.transform.Transformer&quot;
  136. classpathref=&quot;jaxp&quot; property=&quot;jaxp11.present&quot;/&gt;
  137. </pre></blockquote>
  138. <p>sets the <code>jaxp11.present</code> property to the value &quot;true&quot;
  139. if the class <code>javax.xml.transform.Transformer</code> is found in the classpath referenced by <code>jaxp</code> (in this case, <code>./lib/jaxp11/jaxp.jar</code>).
  140. </p>
  141. <blockquote><pre>
  142. &lt;available property=&quot;have.extras&quot; resource=&quot;extratasks.properties&quot;&gt;
  143. &lt;classpath&gt;
  144. &lt;pathelement location=&quot;/usr/local/ant/extra.jar&quot; /&gt;
  145. &nbsp;&nbsp;&lt;/classpath&gt;
  146. &lt;/available&gt;
  147. </pre></blockquote>
  148. <p>sets the <code>have.extras</code> property to the value &quot;true&quot;
  149. if the resource-file <code>extratasks.properties</code> is found.
  150. </p>
  151. </body>
  152. </html>