Meyyappan has posted 101 posts at DZone. View Full User Profile

Ant Properties File

  • submit to reddit

You can also group all the property values in a separate properties file and include it in the ant build file. Here the file contains all the property values. Remember the property value is immutable, so if you set a property value in the properties file you cannot change it in the build file. This give more control over the build process.

The file.


 Use the property task to include the properties file in the Ant build file.

<property file="" />

Here is the complete build file for your reference. 

<?xml version="1.0" ?> 
<project name="AntExample3" default="war">
	<property file="" />

	<path id="compile.classpath">
		<fileset dir="${web.lib.dir}">
			<include name="*.jar"/>
	<target name="init" depends="clean">
		<mkdir dir="${build.classes.dir}"/>
		<mkdir dir="${dist.dir}" />
	<target name="compile" depends="init" >
		<javac destdir="${build.classes.dir}" debug="true" srcdir="src">
			<classpath refid="compile.classpath"/>
	<target name="war" depends="compile">
		<war destfile="${dist.dir}/${}.war" webxml="${web.dir}/WEB-INF/web.xml">
			<fileset dir="${web.dir}"/>
			<lib dir="${web.lib.dir}"/>
			<classes dir="${build.classes.dir}"/>
	<target name="clean">
		<delete dir="${dist.dir}" />
		<delete dir="${build.classes.dir}" />

You can download the build file here. 

 Build File:  Download

Project:  Download


Published at DZone with permission of its author, Meyyappan Muthuraman.

(Note: Opinions expressed in this article and its replies are the opinions of their respective authors and not those of DZone, Inc.)