source: release-kits/lirk3/bin/ant-installer/web/manual/manual/CoreTasks/available.html@ 14982

Last change on this file since 14982 was 14982, checked in by oranfry, 16 years ago

initial import of LiRK3

File size: 6.7 KB
Line 
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
30file, 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
32default; otherwise, the property is not set. You can set the value to
33something 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
35execution 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 &quot;true&quot;.</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=&quot;dir&quot;</code>) or a file
84 (<code>type=&quot;file&quot;</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 &quot;false&quot;</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
111href="../using.html#path">path-like structure</a> and can also be set via a nested
112<code>&lt;classpath&gt;</code> element.</p>
113<h4>filepath</h4>
114<p><code>Available</code>'s <code>filepath</code> attribute is a <a
115href="../using.html#path">path-like structure</a> and can also be set via a nested
116<code>&lt;filepath&gt;</code> element.</p>
117<h3>Examples</h3>
118<blockquote><pre>
119&lt;available classname=&quot;org.whatever.Myclass&quot; property=&quot;Myclass.present&quot;/&gt;
120</pre></blockquote>
121<p>sets the <code>Myclass.present</code> property to the value &quot;true&quot;
122if the class <code>org.whatever.Myclass</code> is found in Ant's classpath.</p>
123<blockquote><pre>
124&lt;property name=&quot;jaxp.jar&quot; value=&quot;./lib/jaxp11/jaxp.jar&quot;/&gt;
125&lt;available file=&quot;${jaxp.jar}&quot; property=&quot;jaxp.jar.present&quot;/&gt;
126</pre></blockquote>
127<p>sets the <code>jaxp.jar.present</code> property to the value &quot;true&quot;
128if the file <code>./lib/jaxp11/jaxp.jar</code> is found.</p>
129<blockquote><pre>
130&lt;available file=&quot;/usr/local/lib&quot; type=&quot;dir&quot;
131 property=&quot;local.lib.present&quot;/&gt;
132</pre></blockquote>
133<p>sets the <code>local.lib.present</code> property to the value &quot;true&quot;
134if the directory <code>/usr/local/lib</code> is found.</p>
135<blockquote><pre>
136...in project ...
137&lt;property name=&quot;jaxp.jar&quot; value=&quot;./lib/jaxp11/jaxp.jar&quot;/&gt;
138&lt;path id=&quot;jaxp&quot; location=&quot;${jaxp.jar}&quot;/&gt;
139...in target ...
140&lt;available classname=&quot;javax.xml.transform.Transformer&quot;
141 classpathref=&quot;jaxp&quot; property=&quot;jaxp11.present&quot;/&gt;
142</pre></blockquote>
143<p>sets the <code>jaxp11.present</code> property to the value &quot;true&quot;
144if 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&lt;available property=&quot;have.extras&quot; resource=&quot;extratasks.properties&quot;&gt;
148 &lt;classpath&gt;
149 &lt;pathelement location=&quot;/usr/local/ant/extra.jar&quot; /&gt;
150&nbsp;&nbsp;&lt;/classpath&gt;
151&lt;/available&gt;
152</pre></blockquote>
153<p>sets the <code>have.extras</code> property to the value &quot;true&quot;
154if the resource-file <code>extratasks.properties</code> is found.
155</p>
156
157
158</body>
159</html>
160
Note: See TracBrowser for help on using the repository browser.