ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Eric Fetzer <elstonk...@yahoo.com>
Subject Re: Merge base settings with environment specific ones
Date Wed, 13 May 2009 19:09:56 GMT
Yeah, the NAnt script would use the <exec> task to call the program with the argument
specifying what environment it was building from.  So in Ant terms:

<for list="dev,qa,uat,prod" param="environment">
    <exec dir="." executable="configure.exe">
          <arg line="@{environment}"/>
    </exec>
    <now configs are set correctly so you stage it for deploy and package it for that
environment using your favorite installation tool/>
</for>




________________________________
From: nagish <jiang.lin@citi.com>
To: user@ant.apache.org
Sent: Wednesday, May 13, 2009 12:54:43 PM
Subject: Re: Merge base settings with environment specific ones


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
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message