Name

available

Synopsis

Conditionally sets a property if a resource is available at runtime. The resource can be a class, file, directory, or Java system resource. If the resource is present, the property is set to true, or whatever the optional value attribute is set to. Otherwise, the property is not set.

Attributes

classname (all, String, *)

A Java class name to look for, such as com.oreilly.book.Author.

classpath (all, Path, N)

The classpath to use when looking up a class name or resource.

classpathref (all, Reference, N)

A reference to a classpath defined elsewhere in the buildfile.

file (all, File, *)

The name of a file to look for.

filepath (1.4, Path, N)

The path of the file.

property (all, String, Y)

The name of the property this task sets if the resource is found.

resource (all, String, *)

A Java resource to look for. For more information on what constitutes a resource, see the various getResource( ) methods in java.lang.ClassLoader.

type (1.4, String, N)

Specifies what the file attribute represents. In Ant 1.4, legal values are "file" or "dir". If not specified, the file attribute represents either a file or directory.

value (all, String, N)

The value assigned to the property if the resource is found. Defaults to "true".

One of classname, file, or resource is required.

Content

0,1 nested <classpath> elements (all)

Path element used in place of the classpath attribute.

0,1 nested <filepath> elements (1.4)

Path element used in place of the filepath attribute.

Example Usage

The following ...

Get Ant: The Definitive Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.