1 | <!--
|
---|
2 | Licensed to the Apache Software Foundation (ASF) under one or more
|
---|
3 | contributor license agreements. See the NOTICE file distributed with
|
---|
4 | this work for additional information regarding copyright ownership.
|
---|
5 | The ASF licenses this file to You under the Apache License, Version 2.0
|
---|
6 | (the "License"); you may not use this file except in compliance with
|
---|
7 | the License. You may obtain a copy of the License at
|
---|
8 |
|
---|
9 | http://www.apache.org/licenses/LICENSE-2.0
|
---|
10 |
|
---|
11 | Unless required by applicable law or agreed to in writing, software
|
---|
12 | distributed under the License is distributed on an "AS IS" BASIS,
|
---|
13 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
---|
14 | See the License for the specific language governing permissions and
|
---|
15 | limitations under the License.
|
---|
16 | -->
|
---|
17 | <html>
|
---|
18 |
|
---|
19 | <head>
|
---|
20 | <meta http-equiv="Content-Language" content="en-us">
|
---|
21 | <link rel="stylesheet" type="text/css" href="../stylesheets/style.css">
|
---|
22 | <title>Available Task</title>
|
---|
23 | </head>
|
---|
24 |
|
---|
25 | <body>
|
---|
26 |
|
---|
27 | <h2><a name="available">Available</a></h2>
|
---|
28 | <h3>Description</h3>
|
---|
29 | <p>Sets a property if a resource is available at runtime. This resource can be a
|
---|
30 | file, a directory, a class in the classpath, or a JVM system resource.</p>
|
---|
31 | <p>If the resource is present, the property value is set to true by
|
---|
32 | default; otherwise, the property is not set. You can set the value to
|
---|
33 | something other than the default by specifying the <code>value</code> attribute.</p>
|
---|
34 | <p>Normally, this task is used to set properties that are useful to avoid target
|
---|
35 | execution depending on system parameters.</p>
|
---|
36 | <h3>Parameters</h3>
|
---|
37 | <table border="1" cellpadding="2" cellspacing="0">
|
---|
38 | <tr>
|
---|
39 | <td valign="top"><b>Attribute</b></td>
|
---|
40 | <td valign="top"><b>Description</b></td>
|
---|
41 | <td align="center" valign="top"><b>Required</b></td>
|
---|
42 | </tr>
|
---|
43 | <tr>
|
---|
44 | <td valign="top">property</td>
|
---|
45 | <td valign="top">The name of the property to set.</td>
|
---|
46 | <td valign="top" align="center">Yes</td>
|
---|
47 | </tr>
|
---|
48 | <tr>
|
---|
49 | <td valign="top">value</td>
|
---|
50 | <td valign="top">The value to set the property to. Defaults to "true".</td>
|
---|
51 | <td valign="top" align="center">No</td>
|
---|
52 | </tr>
|
---|
53 | <tr>
|
---|
54 | <td valign="top">classname</td>
|
---|
55 | <td valign="top">The class to look for in the classpath.</td>
|
---|
56 | <td valign="middle" align="center" rowspan="3">Yes</td>
|
---|
57 | </tr>
|
---|
58 | <tr>
|
---|
59 | <td valign="top">file</td>
|
---|
60 | <td valign="top">The file to look for.</td>
|
---|
61 | </tr>
|
---|
62 | <tr>
|
---|
63 | <td valign="top">resource</td>
|
---|
64 | <td valign="top">The resource to look for in the JVM.</td>
|
---|
65 | </tr>
|
---|
66 | <tr>
|
---|
67 | <td valign="top">classpath</td>
|
---|
68 | <td valign="top">The classpath to use when looking up <code>classname</code> or <code>resource</code>.</td>
|
---|
69 | <td align="center" valign="top">No</td>
|
---|
70 | </tr>
|
---|
71 | <tr>
|
---|
72 | <td valign="top">filepath</td>
|
---|
73 | <td valign="top">The path to use when looking up <code>file</code>.</td>
|
---|
74 | <td align="center" valign="top">No</td>
|
---|
75 | </tr>
|
---|
76 | <tr>
|
---|
77 | <td valign="top">classpathref</td>
|
---|
78 | <td valign="top">The classpath to use, given as a <a href="../using.html#references">reference</a> to a path defined elsewhere.</td>
|
---|
79 | <td align="center" valign="top">No</td>
|
---|
80 | </tr>
|
---|
81 | <tr>
|
---|
82 | <td valign="top">type</td>
|
---|
83 | <td valign="top">The type of <code>file</code> to look for, either a directory (<code>type="dir"</code>) or a file
|
---|
84 | (<code>type="file"</code>). If not set, the property will be set if the name specified in the <code>file</code>
|
---|
85 | attribute exists as either a file or a directory.</td>
|
---|
86 | <td align="center" valign="top">No</td>
|
---|
87 | </tr>
|
---|
88 | <tr>
|
---|
89 | <td valign="top">ignoresystemclasses</td>
|
---|
90 | <td valign="top">Ignore Ant's runtime classes, using only the specified
|
---|
91 | classpath. Only affects the "classname" attribute. Defaults to "false"</td>
|
---|
92 | <td align="center" valign="top">No</td>
|
---|
93 | </tr>
|
---|
94 | <tr>
|
---|
95 | <td valign="top">searchparents</td>
|
---|
96 | <td valign="top">This contains the behaviour of the "file" type.
|
---|
97 | If true, the available task will, when
|
---|
98 | searching for a file, search not only the directories specified but
|
---|
99 | will also search the parent directories of those
|
---|
100 | specified.
|
---|
101 | If false, only the directories specified will be searched.
|
---|
102 | Defaults to "false".
|
---|
103 | <em>Since Ant 1.7</em>
|
---|
104 | </td>
|
---|
105 | <td align="center" valign="top">No</td>
|
---|
106 | </tr>
|
---|
107 | </table>
|
---|
108 | <h3>Parameters specified as nested elements</h3>
|
---|
109 | <h4>classpath</h4>
|
---|
110 | <p><code>Available</code>'s <code>classpath</code> attribute is a <a
|
---|
111 | href="../using.html#path">path-like structure</a> and can also be set via a nested
|
---|
112 | <code><classpath></code> element.</p>
|
---|
113 | <h4>filepath</h4>
|
---|
114 | <p><code>Available</code>'s <code>filepath</code> attribute is a <a
|
---|
115 | href="../using.html#path">path-like structure</a> and can also be set via a nested
|
---|
116 | <code><filepath></code> element.</p>
|
---|
117 | <h3>Examples</h3>
|
---|
118 | <blockquote><pre>
|
---|
119 | <available classname="org.whatever.Myclass" property="Myclass.present"/>
|
---|
120 | </pre></blockquote>
|
---|
121 | <p>sets the <code>Myclass.present</code> property to the value "true"
|
---|
122 | if the class <code>org.whatever.Myclass</code> is found in Ant's classpath.</p>
|
---|
123 | <blockquote><pre>
|
---|
124 | <property name="jaxp.jar" value="./lib/jaxp11/jaxp.jar"/>
|
---|
125 | <available file="${jaxp.jar}" property="jaxp.jar.present"/>
|
---|
126 | </pre></blockquote>
|
---|
127 | <p>sets the <code>jaxp.jar.present</code> property to the value "true"
|
---|
128 | if the file <code>./lib/jaxp11/jaxp.jar</code> is found.</p>
|
---|
129 | <blockquote><pre>
|
---|
130 | <available file="/usr/local/lib" type="dir"
|
---|
131 | property="local.lib.present"/>
|
---|
132 | </pre></blockquote>
|
---|
133 | <p>sets the <code>local.lib.present</code> property to the value "true"
|
---|
134 | if the directory <code>/usr/local/lib</code> is found.</p>
|
---|
135 | <blockquote><pre>
|
---|
136 | ...in project ...
|
---|
137 | <property name="jaxp.jar" value="./lib/jaxp11/jaxp.jar"/>
|
---|
138 | <path id="jaxp" location="${jaxp.jar}"/>
|
---|
139 | ...in target ...
|
---|
140 | <available classname="javax.xml.transform.Transformer"
|
---|
141 | classpathref="jaxp" property="jaxp11.present"/>
|
---|
142 | </pre></blockquote>
|
---|
143 | <p>sets the <code>jaxp11.present</code> property to the value "true"
|
---|
144 | 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>).
|
---|
145 | </p>
|
---|
146 | <blockquote><pre>
|
---|
147 | <available property="have.extras" resource="extratasks.properties">
|
---|
148 | <classpath>
|
---|
149 | <pathelement location="/usr/local/ant/extra.jar" />
|
---|
150 | </classpath>
|
---|
151 | </available>
|
---|
152 | </pre></blockquote>
|
---|
153 | <p>sets the <code>have.extras</code> property to the value "true"
|
---|
154 | if the resource-file <code>extratasks.properties</code> is found.
|
---|
155 | </p>
|
---|
156 |
|
---|
157 |
|
---|
158 | </body>
|
---|
159 | </html>
|
---|
160 |
|
---|