I couldn’t find this easily with TEH GOOGLE so I present to you here, a complete list of the built-in properties that you can access using Ant. If you don’t know what Ant is and you’re a developer, then you probably don’t use deployment scripts and should be whipped. Check out Jim Priest’s Ant Wiki for a boatload of information and helpful links.
You need do nothing else other than wrap these values in with a ${} inside of a build file to use their values. They are a combination of built-in Ant properties and all of System.getProperties():
basedir the absolute path of the project's basedir (as set with the basedir attribute of <project>).
ant.file the absolute path of the buildfile.
ant.version the version of Ant
ant.project.name the name of the project that is currently executing; it is set in the name attribute of <project>.
ant.java.version the JVM version Ant detected; currently it can hold the values "1.2", "1.3", "1.4" and "1.5".
ant.home home directory of Ant
java.version JRE version
java.vendor JRE vendor
java.vendor.url Java vendor URL
java.home Java installation directory
java.vm.specification.version JVM specification version
java.vm.specification.vendor JVM specification vendor
java.vm.specification.name JVM specification name
java.vm.version JVM implementation version
java.vm.vendor JVM implementation vendor
java.vm.name JVM implementation name
java.specification.version JRE specification version
java.specification.vendor JRE specification vendor
java.specification.name JRE specification name
java.class.version Java class format version number
java.class.path Java class path
java.ext.dirs Path of extension directory or directories
os.name Operating system name
os.arch Operating system architecture
os.version Operating system version
file.separator File separator ("/" on UNIX)
path.separator Path separator (":" on UNIX)
line.separator Line separator ("\n" on UNIX)
user.name User's account name
user.home User's home directory
user.dir User's current working directory
If you want to test these, just use echo:
<echo>OS: ${os.arch}</echo>
<echo>VM: ${java.vm.name}</echo>
<echo>Username: ${user.name}</echo>
Finally, you can also get at your environment variables for your system by using the following syntax:
<property environment="env"/>
<echo>Hostname: ${env.COMPUTERNAME}</echo>
<echo>Path: ${env.Path}</echo>
Note that the environment variables are case-sensitive even if your OS is not (e.g., Windows). So for Windows, the variable is env.Path but on Unix (I believe) it would be env.PATH. env.PATH at any rate doesn’t work on Windows so watch your case!
engtech said:
on April 4, 2008 at 7:26 am
Try rake.
It’s the best build tool I’ve tried so far. So simple. So powerful.