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.1 kB

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