ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Erik Hatcher <jakarta-...@ehatchersolutions.com>
Subject Re: loadproperties gotcha
Date Tue, 15 Oct 2002 16:13:23 GMT
Shackelford, John-Mason wrote:
> Then it occurs to me this morning: if we are adding properties only after
> having loaded the HashTable we have no guarantee that the properties are
> truly added in the order specified by the property file, which seems odd to
> me since it means I've been incredibly lucky in nearly 10k + lines of
> buildfiles and scores of properties files I've written in the past six
> months. 
> 
> I knew I had adopted the practice of property composition within property
> files after having read something suggesting it. I didn't see anything in
> the current docs about thiit though and I took a quick look through _Java
> Tools for Extreme Programming_ and _Ant: The Definitive Guide_ but didn't
> see it there either.

But you didn't consult THE definitive guide, _Java Development with Ant_ :)

I quote:

"Loading properties from a properties file
A useful method to provide configuration and settings information to a 
build process
is to load all name/value pairs from a properties file that creates 
internal Ant properties
for each one. To demonstrate: we create a file named build.properties in
the root directory of our project, where our build file lives. This file 
has the following
contents:

build.debug=off

To load it we use one of the variants of the <property> task:

<property file="build.properties"/>

Property values in the properties file may also contain property 
references. For example,
consider a properties file containing these lines:

build.dir=build
output.dir=${build.dir}/output

When loaded, output.dir will have the value build/output. 
Forward-referencing
property values may be used in a single properties file as well; if the 
previous lines
had been in opposite order, the same results would be obtained. Circular 
definitions
will cause a build failure.
NOTE Properties that refer to relative paths are best set using the location
variant. See “Fixing properties to absolute path locations.” Properties set
from a properties file are set as a simple values."

(sorry for the ugly wrapping, cutting and pasting from the PDF file)

I use property file composition like this extensively and it works very 
nicely.

	Erik



--
To unsubscribe, e-mail:   <mailto:ant-user-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:ant-user-help@jakarta.apache.org>


Mime
View raw message