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