Over a million developers have joined DZone.

Ant Properties File


You can also group all the property values in a separate properties file and include it in the ant build file. Here the build.properties 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 build.properties file.


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

<property file="build.properties" />

Here is the complete build file for your reference. 

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

	<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}/${project.name}.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



{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}