Given your Ant file contains something like
<property file="build.properties"/>
<property name="prop1" value="value1"/>
if build.properties contains a line
prop1=valueFromPropertyFile
Then all references to prop1 will give you valueFromPropertyFile.
Best practices would be for all properties to be set in build.xml and have build.properties existence be optional to override specific settings for different environments. These properties can also be overridden on the command line with:
ant -Dprop1=valueFromCommandLine
Command line takes precedence over build.properties which takes precedence over whatever is in build.xml.
Specific examples in the web domain:
- Different IP address to deploy to between production, test, and development.
- Setting a flag to compile with debugging information off and on
- Setting a flag on whether to deploy an exploded war/ear or the packaged version
- Choosing whether to run smoke tests, unit tests, integration tests, acceptance tests or everything
- Different passwords between environments
- Whether to create and populate the database or use an existing one
- Which web.xml to package depending if deploying to Tomcat, GlassFish, JBoss, etc.