ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Matt Small <msm...@Clickability.com>
Subject RE: How can I copy and replace in a file multiple times based on valu es in a loaded props file.
Date Thu, 14 Feb 2002 23:51:30 GMT
Thanks for the response Diane. I really want to keep the databases
indeterminate since I will be doing this for lots of different apps, so it
looks like I am going to go with a custom task. 

Thanks again.

Matt

-----Original Message-----
From: Diane Holt [mailto:holtdl@yahoo.com]
Sent: Thursday, February 14, 2002 3:32 PM
To: Ant Users List
Subject: Re: How can I copy and replace in a file multiple times based
on valu es in a loaded props file.


--- Matt Small <msmall@Clickability.com> wrote:
> Does anybody have any suggestions on what I can do here. I think I can
> do this with the script tag but I'd like to stay away from that.
> Could I do this with a custom task maybe?

You can do just about anything with a custom task :)

But if you'd rather stay away from that as well, then it depends on how
indeterminate the number of DBs you want to do it for really is.

> What I want to do is have ant generically read a dbNames property, and
> for each name in that load a set of configuration params. For each name
> it would copy a properties file into the final app and do the proper
> replacement.
> Thus for each database I would have one database.properties file.
> 
> In the properties file read by ant:
> 
> dbNames=db1,db2
> 
> db1.dbUser=user1
> db1.dbPassword=user1pwd
> db1.dbServer=server1
> db1.dbName=database1
> 
> db2.dbUser=user2
> db2.dbPassword=user2pwd
> db2.dbServer=server2
> db2.dbName=database2

In other words, rather than having this one file to hold all these values,
why not put each in its own properties file? If you do that, and if you
always want to include them all, then things get a bit more doable. But if
you don't, then you'll most probably need to go with a script or custom
task (or at least a couple of the available but non-standard ones, such as
<foreach> and <xproperty>).

> Then I have a database.properties file like this:
> 
> dbUser=@dbUser@
> dbPassword=@dbPassword@
> dbAlias=@dbServer@
>
dbURL=jdbc:informix-sqli://@dbServer@:4004/@dbName@:INFORMIXSERVER=@dbServer
> @;user=@dbUser@;password=@dbPassword@
> 
> That would be replaces such that there would be two properties files in
> my webapp, database_db1.properties and database_db2.properties. My app
> would then know to setup two (or more) database connections.
> 
> Any suggestions are greatly appreciated.

Depends on whether you'd always want all the DBs that you have properties
files for to go, or whether you want to be able to specify only certain
ones.

Diane

=====
(holtdl@yahoo.com)



__________________________________________________
Do You Yahoo!?
Send FREE Valentine eCards with Yahoo! Greetings!
http://greetings.yahoo.com

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

--
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