Predefined Properties
As you've seen already, the property task sets properties that can be referenced later. Ant provides a handful of predefined properties as well as making all the standard Java system properties available. The five Ant-defined properties are
basedirThe value that you set in the basedir attribute of the project tag
ant.fileThe full path name of the build file being executed
ant.versionThe version of the currently executing Ant instance
ant.project.nameThe value from the name attribute of the project tag
ant.java.versionThe version of the Java VM that Ant detected at runtime
You can access any of these properties from your own targets. For example, if you wanted to name a JAR file with the same name as the project, you could write a property as shown in Listing 3.76.
Listing 3.76 Referencing a Predefined Property
<property name="jar.name" value="${ant.project.name}.jar"/>
Similarly, you can get to any property that would be returned by a call to System.getProperties() in your Java code. Some of these properties include:
os.nameThe operating system Ant is running on
os.versionThe version of the current operating system
java.class.pathThe classpath Ant is using
user.homeThe current user's home directory
Many more system properties are available. Consult the JavaDoc for java.lang.System.getProperties() for the full list.