ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Diane Holt <>
Subject Re: global properties
Date Thu, 20 Sep 2001 21:34:03 GMT
--- Craig Longman <> wrote:
> so, assuming these properties:
> db.port=1234
> db.dbname=test_db
> db.uid=dba
> db.pwd=dba

> db.type.pgsql=true
>  OR
> db.type.db2=true

If you're going to pass the type in on the command line -- eg:
  $ ant -Dtype=db2 deploy   # or whatever you call your deployment target
you can reduce your "init" target's <antcall>'s to only one, which has:
  <antcall target="db.${type}"/>
and change the db-pgsql and db-db2 targets to use <propertyfile> to add
the properties they set to the "" file (or whatever
you're calling the file that has, etc. in it) instead. Then have
"init" read the file in. Get rid of all the 'depends' and 'if's (and the
props they were if'ing against) and the check-db-config target.

In other words:

<target name="deploy" depends="dbconfig">
  <echo message="   = ${}"/>
  <echo message="db.port   = ${db.port}"/>
  <echo message="   = ${}"/>
  <echo message="db.uid    = ${db.uid}"/>
  <echo message="db.pwd    = ${db.pwd}"/>
  <echo message="db.url    = ${db.url}"/>
  <echo message="db.driver = ${db.driver}"/>

<target name="dbconfig">
  <antcall target="db-${type}"/>
  <property file=""/>

<target name="db-db2">
  <propertyfile file="">
    <entry key="db.url"
    <entry key="db.driver" value=""/>

<target name="db-pgsql">
  <propertyfile file="">
    <entry key="db.url"
    <entry key="db.driver" value="org.postgresql.Driver"/>

$ ant -Dtype=db2 deploy
     [propertyfile] Updating property file:

     [echo]   =
     [echo] db.port   = 1234
     [echo]   = test_db
     [echo] db.uid    = dba
     [echo] db.pwd    = dba
     [echo] db.url    =
     [echo] db.driver =

Note: If your "" file is source-controlled, so it ends
up being read-only in your build tree, you'll need to work that out.



Terrorist Attacks on U.S. - How can you help?
Donate cash, emergency relief information

View raw message