How do I use a build.properties file?
Author: Deron Eriksson
Description: This tutorial describes how to use an Ant build.properties file.
Tutorial created using: Windows XP || JDK 1.5.0_09 || Eclipse Web Tools Platform 1.5.1


Page: < 1 2

(Continued from page 1)

The build.properties file used in this tutorial is shown below. I originally created the project-name, builder, ftp-server, ftp-userid, and ftp-password properties and placed them in my build.xml file. I removed these properties from build.xml and put them in build.properties. My build.xml file contains a property pointing to the build.properties file, and the build.properties file contains the names and values of the 5 aforementioned properties.

build.properties

#build.properties file
project-name=tomcat-demo
builder=TeamCakes
ftp-server=SERVER_GOES_HERE
ftp-userid=USERID_GOES_HERE
ftp-password=PASSWORD_GOES_HERE

I can execute the 'all' target by double-clicking the tomcat-demo project's 'all' target in the AntSW view in EclipseSW.

executing 'all' target in Ant View

The execution of the 'all' target is shown in Eclipse's console.

execution of 'all' target in Console

As you can see, build.properties files are very easy to use. They offer a convenient way of extracting out properties from your build.xml files. This can be useful for things such as creating build.xml files that can be run for different projects or different environments, where the differences are contained in different versions of the build.properties files that utilize the same build.xml file.

Page: < 1 2