2001-02-13 12:32:01 +00:00
< html >
< head >
< meta http-equiv = "Content-Language" content = "en-us" >
2001-10-30 10:05:39 +00:00
< title > Apache Ant User Manual< / title >
2001-02-13 12:32:01 +00:00
< / head >
< body >
< h2 > < a name = "available" > Available< / a > < / h2 >
< h3 > Description< / h3 >
< p > Sets a property if a resource is available at runtime. This resource can be a
2001-04-30 23:25:36 +00:00
file, a directory, a class in the classpath, or a JVM system resource.< / p >
2001-02-13 12:32:01 +00:00
< p > If the resource is present, the property value is set to true by
2001-05-03 07:41:11 +00:00
default; otherwise, the property is not set. You can set the value to
something other than the default by specifying the < code > value< / code > attribute.< / p >
2001-02-13 12:32:01 +00:00
< p > Normally, this task is used to set properties that are useful to avoid target
execution depending on system parameters.< / p >
< h3 > Parameters< / h3 >
< table border = "1" cellpadding = "2" cellspacing = "0" >
< tr >
< td valign = "top" > < b > Attribute< / b > < / td >
< td valign = "top" > < b > Description< / b > < / td >
< td align = "center" valign = "top" > < b > Required< / b > < / td >
< / tr >
< tr >
< td valign = "top" > property< / td >
2001-04-30 23:25:36 +00:00
< td valign = "top" > The name of the property to set.< / td >
2001-02-13 12:32:01 +00:00
< td valign = "top" align = "center" > Yes< / td >
< / tr >
< tr >
< td valign = "top" > value< / td >
2001-04-30 23:25:36 +00:00
< td valign = "top" > The value to set the property to. Defaults to " true" .< / td >
2001-02-13 12:32:01 +00:00
< td valign = "top" align = "center" > No< / td >
< / tr >
< tr >
< td valign = "top" > classname< / td >
2001-04-30 23:25:36 +00:00
< td valign = "top" > The class to look for in the classpath.< / td >
2001-05-03 07:41:11 +00:00
< td valign = "middle" align = "center" rowspan = "3" > Yes< / td >
2001-02-13 12:32:01 +00:00
< / tr >
< tr >
< td valign = "top" > file< / td >
2001-04-30 23:25:36 +00:00
< td valign = "top" > The file to look for.< / td >
< / tr >
< tr >
< td valign = "top" > resource< / td >
< td valign = "top" > The resource to look for in the JVM.< / td >
2001-02-13 12:32:01 +00:00
< / tr >
< tr >
2001-05-03 07:41:11 +00:00
< td valign = "top" > classpath< / td >
< td valign = "top" > The classpath to use when looking up < code > classname< / code > or < code > resource< / code > .< / td >
< td align = "center" valign = "top" > No< / td >
2001-02-13 12:32:01 +00:00
< / tr >
2001-08-30 13:23:14 +00:00
< tr >
< td valign = "top" > filepath< / td >
< td valign = "top" > The path to use when looking up < code > file< / code > .< / td >
< td align = "center" valign = "top" > No< / td >
< / tr >
2001-02-13 12:32:01 +00:00
< tr >
< td valign = "top" > classpathref< / td >
2001-05-03 07:41:11 +00:00
< td valign = "top" > The classpath to use, given as a < a href = "../using.html#references" > reference< / a > to a path defined elsewhere.< / td >
< td align = "center" valign = "top" > No< / td >
< / tr >
< tr >
< td valign = "top" > type< / td >
2001-08-30 13:23:14 +00:00
< 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 >
2001-02-13 12:32:01 +00:00
< td align = "center" valign = "top" > No< / td >
< / tr >
< / table >
< h3 > Parameters specified as nested elements< / h3 >
< h4 > classpath< / h4 >
2001-04-30 23:25:36 +00:00
< p > < code > Available< / code > 's < code > classpath< / code > attribute is a < a
2001-02-13 12:32:01 +00:00
href="../using.html#path">path-like structure< / a > and can also be set via a nested
2001-04-30 23:25:36 +00:00
< code > < classpath> < / code > element.< / p >
2001-08-30 13:23:14 +00:00
< h4 > filepath< / h4 >
< p > < code > Available< / code > 's < code > filepath< / code > attribute is a < a
href="../using.html#path">path-like structure< / a > and can also be set via a nested
< code > < filepath> < / code > element.< / p >
2001-02-13 12:32:01 +00:00
< h3 > Examples< / h3 >
< pre > < available classname=" org.whatever.Myclass" property=" Myclass.present" /> < / pre >
2001-04-30 23:25:36 +00:00
< p > sets the < code > Myclass.present< / code > property to the value " true"
if the class < code > org.whatever.Myclass< / code > is found in Ant's classpath.< / p >
2001-02-13 12:32:01 +00:00
< pre >
< property name=" jaxp.jar" value=" ./lib/jaxp11/jaxp.jar" />
< available file=" ${jaxp.jar}" property=" jaxp.jar.present" />
< / pre >
2001-04-30 23:25:36 +00:00
< p > sets the < code > jaxp.jar.present< / code > property to the value " true"
if the file < code > ./lib/jaxp11/jaxp.jar< / code > is found.< / p >
2001-02-13 12:32:01 +00:00
< pre >
2001-05-03 07:41:11 +00:00
< available file=" /usr/local/lib" type=" dir" property=" local.lib.present" />
< / pre >
< p > sets the < code > local.lib.present< / code > property to the value " true"
if the directory < code > /usr/local/lib< / code > is found.< / p >
< pre >
2001-02-13 12:32:01 +00:00
...in project ...
< property name=" jaxp.jar" value=" ./lib/jaxp11/jaxp.jar" />
< path id=" jaxp" location=" ${jaxp.jar}" />
...in target ...
< available classname=" javax.xml.transform.Transformer" classpathref=" jaxp" property=" jaxp11.present" />
< / pre >
2001-04-30 23:25:36 +00:00
< p > sets the < code > jaxp11.present< / code > property to the value " true"
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 > ).
< / p >
< pre >
< available property=" have.extras" resource=" extratasks.properties" >
< classpath>
< pathelement location=" /usr/local/ant/extra.jar/>
< /classpath>
< /available>
< / pre >
< p > sets the < code > have.extras< / code > property to the value " true"
if the resource-file < code > extratasks.properties< / code > is found.
2001-02-13 12:32:01 +00:00
< / p >
2002-01-10 08:48:33 +00:00
< hr > < p align = "center" > Copyright © 2001 Apache Software Foundation. All rights
2001-02-13 12:32:01 +00:00
Reserved.< / p >
< / body >
< / html >