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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  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. </table>
  76. <h3>Parameters specified as nested elements</h3>
  77. <h4>classpath</h4>
  78. <p><code>Available</code>'s <code>classpath</code> attribute is a <a
  79. href="../using.html#path">path-like structure</a> and can also be set via a nested
  80. <code>&lt;classpath&gt;</code> element.</p>
  81. <h4>filepath</h4>
  82. <p><code>Available</code>'s <code>filepath</code> attribute is a <a
  83. href="../using.html#path">path-like structure</a> and can also be set via a nested
  84. <code>&lt;filepath&gt;</code> element.</p>
  85. <h3>Examples</h3>
  86. <blockquote><pre>
  87. &lt;available classname=&quot;org.whatever.Myclass&quot; property=&quot;Myclass.present&quot;/&gt;
  88. </pre></blockquote>
  89. <p>sets the <code>Myclass.present</code> property to the value &quot;true&quot;
  90. if the class <code>org.whatever.Myclass</code> is found in Ant's classpath.</p>
  91. <blockquote><pre>
  92. &lt;property name=&quot;jaxp.jar&quot; value=&quot;./lib/jaxp11/jaxp.jar&quot;/&gt;
  93. &lt;available file=&quot;${jaxp.jar}&quot; property=&quot;jaxp.jar.present&quot;/&gt;
  94. </pre></blockquote>
  95. <p>sets the <code>jaxp.jar.present</code> property to the value &quot;true&quot;
  96. if the file <code>./lib/jaxp11/jaxp.jar</code> is found.</p>
  97. <blockquote><pre>
  98. &lt;available file=&quot;/usr/local/lib&quot; type=&quot;dir&quot;
  99. property=&quot;local.lib.present&quot;/&gt;
  100. </pre></blockquote>
  101. <p>sets the <code>local.lib.present</code> property to the value &quot;true&quot;
  102. if the directory <code>/usr/local/lib</code> is found.</p>
  103. <blockquote><pre>
  104. ...in project ...
  105. &lt;property name=&quot;jaxp.jar&quot; value=&quot;./lib/jaxp11/jaxp.jar&quot;/&gt;
  106. &lt;path id=&quot;jaxp&quot; location=&quot;${jaxp.jar}&quot;/&gt;
  107. ...in target ...
  108. &lt;available classname=&quot;javax.xml.transform.Transformer&quot;
  109. classpathref=&quot;jaxp&quot; property=&quot;jaxp11.present&quot;/&gt;
  110. </pre></blockquote>
  111. <p>sets the <code>jaxp11.present</code> property to the value &quot;true&quot;
  112. 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>).
  113. </p>
  114. <blockquote><pre>
  115. &lt;available property=&quot;have.extras&quot; resource=&quot;extratasks.properties&quot;&gt;
  116. &lt;classpath&gt;
  117. &lt;pathelement location=&quot;/usr/local/ant/extra.jar/&gt;
  118. &nbsp;&nbsp;&lt;/classpath&gt;
  119. &lt;/available&gt;
  120. </pre></blockquote>
  121. <p>sets the <code>have.extras</code> property to the value &quot;true&quot;
  122. if the resource-file <code>extratasks.properties</code> is found.
  123. </p>
  124. <hr><p align="center">Copyright &copy; 2000-2002,2004-2005 The Apache Software Foundation. All rights
  125. Reserved.</p>
  126. </body>
  127. </html>