ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nagish <jiang....@citi.com>
Subject Re: Merge base settings with environment specific ones
Date Wed, 13 May 2009 18:54:43 GMT

Thanks Eric. If I understood you correctly, it's that program you wrote that
did the trick for you, not the NAnt script. Is it correct? Thanks.

Eric Fetzer wrote:
> 
> OK, so here's what I did with NAnt and a C# .Net project for this same
> problem.  My properties files were all xml, so I wrote a program that read
> a master config file and based on what argument was passed for
> <environment>, the program went into the config file it was configuring at
> the designated xpath and set that node value to the specified
> environmental value.  So the master config file looked something like
> this:
> 
> <xml...>
>   <configfile file="C:\program files\myfile.xml">
>     <xpath
> value="configuration/appSettings/key[@key="connectionString"]/@value">
>       <environments>
>         <env dev="myConnectionStringForDev"/>
>         <env qa="myConnectionStringForQA"/>
>         <env prod="myConnectionStringForProd"/>
>       </environments>
>     </xpath>
>     <xpath value="configuration/appSettings/key[@key="dogHouse"]/@value"> 
>       <environments>
>         <env dev="devDogHouse"/>
>         <env qa="qaDogHouse"/>
>         <env prod="prodDogHouse"/>
>       </environments>
>     </xpath>
>   </configfile>
>   <configfile file="C:\program files\anotherConfigfile.xml">
>     <xpath
> value="configuration/appSettings/key[@key="connectionString"]/@value">
>       <environments>
>         <env dev="myConnectionStringForDev"/>
>         <env qa="myConnectionStringForQA"/>
>         <env prod="myConnectionStringForProd"/>
>       </environments>
>     </xpath>
>     <xpath value="configuration/appSettings/key[@key="dogHouse"]/@value"> 
>       <environments>
>         <env dev="devDogHouse"/>
>         <env qa="qaDogHouse"/>
>         <env prod="prodDogHouse"/>
>       </environments>
>     </xpath>
>   </configfile>
> </xml...>
> 
> Seems something similar could be done for non-xml files as well using
> global substitution using regex or such...
> 

-- 
View this message in context: http://www.nabble.com/Merge-base-settings-with-environment-specific-ones-tp23524997p23527870.html
Sent from the Ant - Users mailing list archive at Nabble.com.


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


Mime
View raw message