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 | <blockquote><pre>
|
---|
91 | <available classname="org.whatever.Myclass" property="Myclass.present"/>
|
---|
92 | </pre></blockquote>
|
---|
93 | <p>sets the <code>Myclass.present</code> property to the value "true"
|
---|
94 | if the class <code>org.whatever.Myclass</code> is found in Ant's classpath.</p>
|
---|
95 | <blockquote><pre>
|
---|
96 | <property name="jaxp.jar" value="./lib/jaxp11/jaxp.jar"/>
|
---|
97 | <available file="${jaxp.jar}" property="jaxp.jar.present"/>
|
---|
98 | </pre></blockquote>
|
---|
99 | <p>sets the <code>jaxp.jar.present</code> property to the value "true"
|
---|
100 | if the file <code>./lib/jaxp11/jaxp.jar</code> is found.</p>
|
---|
101 | <blockquote><pre>
|
---|
102 | <available file="/usr/local/lib" type="dir"
|
---|
103 | property="local.lib.present"/>
|
---|
104 | </pre></blockquote>
|
---|
105 | <p>sets the <code>local.lib.present</code> property to the value "true"
|
---|
106 | if the directory <code>/usr/local/lib</code> is found.</p>
|
---|
107 | <blockquote><pre>
|
---|
108 | ...in project ...
|
---|
109 | <property name="jaxp.jar" value="./lib/jaxp11/jaxp.jar"/>
|
---|
110 | <path id="jaxp" location="${jaxp.jar}"/>
|
---|
111 | ...in target ...
|
---|
112 | <available classname="javax.xml.transform.Transformer"
|
---|
113 | classpathref="jaxp" property="jaxp11.present"/>
|
---|
114 | </pre></blockquote>
|
---|
115 | <p>sets the <code>jaxp11.present</code> property to the value "true"
|
---|
116 | 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>).
|
---|
117 | </p>
|
---|
118 | <blockquote><pre>
|
---|
119 | <available property="have.extras" resource="extratasks.properties">
|
---|
120 | <classpath>
|
---|
121 | <pathelement location="/usr/local/ant/extra.jar" />
|
---|
122 | </classpath>
|
---|
123 | </available>
|
---|
124 | </pre></blockquote>
|
---|
125 | <p>sets the <code>have.extras</code> property to the value "true"
|
---|
126 | if the resource-file <code>extratasks.properties</code> is found.
|
---|
127 | </p>
|
---|
128 | <hr><p align="center">Copyright © 2000-2002,2004-2005 The Apache Software Foundation. All rights
|
---|
129 | Reserved.</p>
|
---|
130 |
|
---|
131 | </body>
|
---|
132 | </html>
|
---|
133 |
|
---|