Using Filters
You can use filters to replace tokens in a configuration file with their proper values for the deployment environment (see Listing 20.6). Filters are another way to support multiple deployment environments. Let's look at a case where you have both a production database and a development database. When deploying, you want the production value (jdbc_url in Listing 20.6) to refer to the correct database.
<project name="hello" default="run">
<target name="setupProduction" if="production">
<filter token="jdbc_url" value="jdbc:rdbms:production"/> </target>
<target name="setupDevelopment" unless="production">
<filter token="jdbc_url" value="jdbc:rdbms:development"/> </target>
<target name="setup" depends="setupProduction,setupDevelopment"/>
<target name="run" depends="setup">
<copy todir="/usr/home/production/properties" filtering="true"> <fileset dir="/cvs/src/properties"/>
</copy>
</target>
</project>
Listing 20.6