ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Stefan Bodewig <bode...@apache.org>
Subject Re: Resolving of variables
Date Fri, 12 Jan 2001 15:49:48 GMT
Mariano Kamp <mkamp@codamax.com> wrote:

>   This parameter is passed to ant on the command line and everything
>   is working fine. The only problem is for launching the sql script
>   that I need to provide some parameters like the database url. In
>   ant I have the parameters defined like this:
> 
>   <property name="db.oracle.url"   .../>
>   <property name="db.postgres.url" .../>
> 
> I don't have a clue about how to select one of these values at
> runtime. I pass in a parameter called db which holds for example
> "oracle". What I tried was:
> 
>   <sql url="${db.${db}.driver}" ...../>
> 
> Which isn't working ... Is there any alternative to solve my
> problem?

Yes there is.

First, what you do is not working because Ant doesn't recurse when
expanding properties.

Now to the alternative solution: 

Place the properties in an external file, something like

oracle.properties:
------------------
db.driver=...
db.url=...

postgres.properties:
------------------
db.driver=...
db.url=...

And in your buildfile use

<property file="${db}.properties" />
...
<sql url="${db.url}" driver="${db.driver}" ... />

and so on.

Stefan

Mime
View raw message