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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. <html>
  2. <head>
  3. <meta http-equiv="Content-Language" content="en-us">
  4. <title>Ant User Manual</title>
  5. </head>
  6. <body>
  7. <h2><a name="available">Available</a></h2>
  8. <h3>Description</h3>
  9. <p>Sets a property if a resource is available at runtime. This resource can be a
  10. file, a directory, a class in the classpath, or a JVM system resource.</p>
  11. <p>If the resource is present, the property value is set to true by
  12. default; otherwise, the property is not set. You can set the value to
  13. something other than the default by specifying the <code>value</code> attribute.</p>
  14. <p>Normally, this task is used to set properties that are useful to avoid target
  15. execution depending on system parameters.</p>
  16. <h3>Parameters</h3>
  17. <table border="1" cellpadding="2" cellspacing="0">
  18. <tr>
  19. <td valign="top"><b>Attribute</b></td>
  20. <td valign="top"><b>Description</b></td>
  21. <td align="center" valign="top"><b>Required</b></td>
  22. </tr>
  23. <tr>
  24. <td valign="top">property</td>
  25. <td valign="top">The name of the property to set.</td>
  26. <td valign="top" align="center">Yes</td>
  27. </tr>
  28. <tr>
  29. <td valign="top">value</td>
  30. <td valign="top">The value to set the property to. Defaults to &quot;true&quot;.</td>
  31. <td valign="top" align="center">No</td>
  32. </tr>
  33. <tr>
  34. <td valign="top">classname</td>
  35. <td valign="top">The class to look for in the classpath.</td>
  36. <td valign="middle" align="center" rowspan="3">Yes</td>
  37. </tr>
  38. <tr>
  39. <td valign="top">file</td>
  40. <td valign="top">The file to look for.</td>
  41. </tr>
  42. <tr>
  43. <td valign="top">resource</td>
  44. <td valign="top">The resource to look for in the JVM.</td>
  45. </tr>
  46. <tr>
  47. <td valign="top">classpath</td>
  48. <td valign="top">The classpath to use when looking up <code>classname</code> or <code>resource</code>.</td>
  49. <td align="center" valign="top">No</td>
  50. </tr>
  51. <tr>
  52. <td valign="top">classpathref</td>
  53. <td valign="top">The classpath to use, given as a <a href="../using.html#references">reference</a> to a path defined elsewhere.</td>
  54. <td align="center" valign="top">No</td>
  55. </tr>
  56. <tr>
  57. <td valign="top">type</td>
  58. <td valign="top">The type of <code>file</code> to look for, either a directory (<code>type="dir"</code>) or a file (<code>type="file"</code>). If not set, the property will be set if the name specified in the <code>file</code> attribute exists as either a file or a directory.</td>
  59. <td align="center" valign="top">No</td>
  60. </tr>
  61. </table>
  62. <h3>Parameters specified as nested elements</h3>
  63. <h4>classpath</h4>
  64. <p><code>Available</code>'s <code>classpath</code> attribute is a <a
  65. href="../using.html#path">path-like structure</a> and can also be set via a nested
  66. <code>&lt;classpath&gt;</code> element.</p>
  67. <h3>Examples</h3>
  68. <pre> &lt;available classname=&quot;org.whatever.Myclass&quot; property=&quot;Myclass.present&quot;/&gt;</pre>
  69. <p>sets the <code>Myclass.present</code> property to the value &quot;true&quot;
  70. if the class <code>org.whatever.Myclass</code> is found in Ant's classpath.</p>
  71. <pre>
  72. &lt;property name=&quot;jaxp.jar&quot; value=&quot;./lib/jaxp11/jaxp.jar&quot;/&gt;
  73. &lt;available file=&quot;${jaxp.jar}&quot; property=&quot;jaxp.jar.present&quot;/&gt;
  74. </pre>
  75. <p>sets the <code>jaxp.jar.present</code> property to the value &quot;true&quot;
  76. if the file <code>./lib/jaxp11/jaxp.jar</code> is found.</p>
  77. <pre>
  78. &lt;available file=&quot;/usr/local/lib&quot; type=&quot;dir&quot; property=&quot;local.lib.present&quot;/&gt;
  79. </pre>
  80. <p>sets the <code>local.lib.present</code> property to the value &quot;true&quot;
  81. if the directory <code>/usr/local/lib</code> is found.</p>
  82. <pre>
  83. ...in project ...
  84. &lt;property name=&quot;jaxp.jar&quot; value=&quot;./lib/jaxp11/jaxp.jar&quot;/&gt;
  85. &lt;path id=&quot;jaxp&quot; location=&quot;${jaxp.jar}&quot;/&gt;
  86. ...in target ...
  87. &lt;available classname=&quot;javax.xml.transform.Transformer&quot; classpathref=&quot;jaxp&quot; property=&quot;jaxp11.present&quot;/&gt;
  88. </pre>
  89. <p>sets the <code>jaxp11.present</code> property to the value &quot;true&quot;
  90. 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>).
  91. </p>
  92. <p>
  93. <pre>
  94. &lt;available property=&quot;have.extras&quot; resource=&quot;extratasks.properties&quot;&gt;
  95. &lt;classpath&gt;
  96. &lt;pathelement location=&quot;/usr/local/ant/extra.jar/&gt;
  97. &nbsp;&nbsp;&lt;/classpath&gt;
  98. &lt;/available&gt;
  99. </pre>
  100. <p>sets the <code>have.extras</code> property to the value &quot;true&quot;
  101. if the resource-file <code>extratasks.properties</code> is found.
  102. </p>
  103. <hr><p align="center">Copyright &copy; 2000,2001 Apache Software Foundation. All rights
  104. Reserved.</p>
  105. </body>
  106. </html>