ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Ludwig, Michael" <Michael.Lud...@delphi-mb.de>
Subject RE: Search for properties file in parent directories
Date Thu, 11 Nov 2010 18:02:58 GMT
Merci Antoine et Dominique!

> But may I inquire why you need that?

Of course. :-) I don't really need this, I was just wondering whether
it was possible. I could have maintained different configurations in
different subdirectories, overriding configurations in directories
higher up the tree. A user could descend into a directory, and Ant
would start to search for a configuration in the current directory,
recursively defaulting to the parent directory.

<!-- not implemented! -->
<property file="rz.properties" start="${user.dir}" search="upwards"/>

It's probably a bad idea. Just forget about it. (And if you can't,
it's not too difficult to implement yourself.)

> In my experience, properties files are in known locations, either
> absolute, or more likely relative to the "basedir", or some file.

I probably wouldn't have thought of this, let alone asked the list,
if it weren't for ant's -s/-find command line option.

> For example, If in your case the .properties is in config/ relative to
> the build.xml that would found via the -s CLI switch, you can load the
> properties file using <property file="${basedir}/config/rz.properties"
> />, whereas <property file="rz.properties" /> uses either ${basedir}
> or the current directory (I don't remember which).

It uses ${basedir}, not the current directory:

<project>
        <typedef resource="org/tigris/subversion/svnant/svnantlib.xml" />
        <property file="propfiletest.properties" prefix="pft"/>
        <echoproperties prefix="pft"/>
</project>

D:\dvinci\ant :: ant -e -f propfiletest.xml
Buildfile: D:\dvinci\ant\propfiletest.xml
#Ant properties
#Thu Nov 11 18:46:39 CET 2010
pft.abc=3
pft.def=6

D:\dvinci\ant :: ant -e -f propfiletest.xml -Dbasedir=..
Buildfile: D:\dvinci\ant\propfiletest.xml
#Ant properties
#Thu Nov 11 18:46:41 CET 2010

D:\dvinci :: ant -e -f ant\propfiletest.xml
Buildfile: D:\dvinci\ant\propfiletest.xml
#Ant properties
#Thu Nov 11 18:49:03 CET 2010
pft.abc=3
pft.def=6

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


Mime
View raw message