Developing Web Applications With Ant by Richard Hightower - HTML preview

PLEASE NOTE: This is an HTML preview only and some elements such as links or page numbers may be incorrect.
Download the book in PDF, ePub, Kindle for a complete version.

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

Find Your Next Great Read

Describe what you're looking for in as much detail as you'd like.
Our AI reads your request and finds the best matching books for you.

Showing results for ""

Popular searches:

Romance Mystery & Thriller Self-Help Sci-Fi Business