There are several ways to do just this.

1. Use the -D option to define the properties you want.
2. Use the -propertyfile flag to specify a property file
3. Use the <properties file=""> field to specify which properties are
stored in a particular file.

If possible, you can define default values for the properties you
want, and then over ride them via these other methods. For example, if
you use #1 the values specified will override the default values in
your build.xml file, you have the following:

<property name="host" value="1.2.3.4"/>
<property name="port" value="1234"/>
[...]
<host value="${host}" port="${port}"/>

And you put this on the command line:

$ ant -Dhost=5.6.7.8 -Dport=5678

host will be set to "5.6.7.8" and not "1.2.3.4". And, port will be set
to 5678 and not 1234.

You can put a bunch of files into a properties file in the form of:

host=5.6.7.8
port=5678

and that too will override the properties you've set with <properties>
statements.

I prefer to do something like this:

<property name="properties.file" value="${basedir}/build.properties"/>
<property file="${properties.file}"/>

This allows someone to use a default properties file or to override
the default one on the command line via the -D option.

My preference is to use default values in the build.xml and allow the
user to override them on the command line. This meshes with my
philosophy that a developer just typing "ant" on the command line will
do more or less what they expect.

If you don't specify default values, you should use <fail> tasks to
fail the build when particular values are not set by the use via the
command line:

<fail unless="host"  message="You must set the property &quot;host&quot;"/>

-- 
David Weintraub
qazw...@gmail.com

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscr...@ant.apache.org
For additional commands, e-mail: user-h...@ant.apache.org

Reply via email to