Apache Ant Properties

Properties are key-value pairs where each value is associated to a key. The property is used to set value which can be accessed anywhere in the buildfile. Once a property is set, it cannot be changed.

Apache Ant provides <property> tag which can be used to set property.

Apache Ant Property Types

  1. Built-in Properties
  2. User defined Properties

Apache Ant Built-in Properties

Apache Ant provides various built-in properties and we can access all these properties in our buildfile. Some built-in properties are given below.

PropertyDescription
basedirIt is used for the absolute path of the project's basedir.
ant.fileIt is used for the absolute path of the buildfile.
ant.version It is used for the version of Ant.
ant.project.nameIt holds name of the project that is currently executing.
ant.project.default-targetIt holds name of the currently executing project's default target.
ant.project.invoked-targetsA list of the targets when invoking the current project.
ant.java.versionIt holds the JVM version.
ant.core.libthe absolute path of the ant.jar file.
ant.homeIt contains home directory of Ant.
ant.library.dirIt holds the directory that has been used to load Ant's jars from.

Apache Ant User defined Properties

Apart from built-in properties, Apache Ant also provides the facility to create custom properties in buildfile.

To create properties, <property> tag is provided which uses name and value attributes. The name attribute is the name of the property and value attribute holds a value.

To understand further, let's see an example.

Apache Ant Property Example

// build.xml

Output:


Apache Ant Properties




Latest Courses