ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Antoine Levy-Lambert <anto...@gmx.de>
Subject Re: Search for properties file in parent directories
Date Thu, 11 Nov 2010 16:41:41 GMT
  Hello Michael,

I do not know of any way of doing this in a generic fashion.

If you have few levels of directories and the number of directories is 
known,  you can write this :

<property file="abc.properties"/>
<property file="../abc.properties"/>
<property file="../../abc.properties/>
<property file="../../../abc.properties"/>

this will not bail out if one of the property files does not exists and 
it will read the files in the order of the ant xml.
As usual with properties, when a key/value pair is found it is not 
modifiable afterwards.

You may want to create a custom task which does what you need, 
especially if you have use cases with different numbers of directories 
to look in ... You can pretty well write a custom task which eithers 
extends the property task of ant or delegates to it.

Regards,

Antoine

On 11/11/2010 5:33 AM, Ludwig, Michael wrote:
> On the command line, I can instruct ant to go searching for a build
> file by climbing up the directory tree:
>
> ant -h
>    ...
>    -find<file>            (s)earch for buildfile towards the root of
>      -s<file>            the filesystem and use it
>
>  From within a script, I can instruct ant to load properties from a
> file using<property file="rz.properties"/>.
>
> Is there a way to instruct Ant to go searching for the properties
> file by climbing up the directory tree, just like "ant -s" does
> for build files?
>


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


Mime
View raw message