You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by Peter Wilkes <pw...@cowpie.acm.vt.edu> on 2004/10/21 20:57:12 UTC

auto configuration

hello!

i just convinced my project to user ant. they think it is a great tool and
we are currently trying to move all our build scripts over.

i have a question however.

our application only gets delivered to currently 5 locations. (it's a
specialized program) and we would like to make a configuration file for
each site.

right now we have a general properties file called "program.properties"
and we have an install proceedure to change certain lines.

we would like to set up ant persay to read in another file called
"site1.properties" read in all the properties and automatically change the
values to the proper values need for site1 in program.properties.

ex.
in program.properties
------
option1= OPTION1_REPLACE
option2= OPTION2_REPLACE
--------

then in site1.properties
-------
option1=text
option2=othertext
-------


the reason is 3 fold. 1. our config fil is 70% the same for each site and
2. reduce error on install instructions. 3. we have 3 different
configuration files for 3 different sections of the program (don't ask me
why) and i figured instead of creating 15 configuration files then i would
have 8 files. 3 config files and 1 for each site with the replacements to
make.

i;ve been suggested to create a

site1.program.properties
site2.program.properties

and copy the appropriate properties file in the build script however i
believe this would be bad since a developer might forget to  update all 15
files.


thanks for any help!

Pete


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


Re: auto configuration

Posted by "Frode E. Moe" <fr...@CoreTrek.no>.
On Thu, Oct 21, 2004 at 14:57:12 -0400, Peter Wilkes wrote:
> right now we have a general properties file called "program.properties"
> and we have an install proceedure to change certain lines.
> 
> we would like to set up ant persay to read in another file called
> "site1.properties" read in all the properties and automatically change the
> values to the proper values need for site1 in program.properties.
> 
> ex.
> in program.properties
> ------
> option1= OPTION1_REPLACE
> option2= OPTION2_REPLACE
> --------
> 
> then in site1.properties
> -------
> option1=text
> option2=othertext
> -------

Sounds like you need FilterSets:

http://ant.apache.org/manual/CoreTypes/filterset.html

In program.properties.template you then put:
option1= %OPTION1_REPLACE%
option2= %OPTION2_REPLACE%

Then you can read "site1.properties" as above with
<property file="site1.properties" prefix="siteconfig.properties" /> 

Then you can create the real prorgram.properties like this:

<copy file="program.properties.template" toFile="program.properties">
  <filterset begintoken="%" endtoken="%"> 
    <filter token="OPTION1_REPLACE"   value="${siteconfig.properties.option1}" />
    <filter token="OPTION2_REPLACE"   value="${siteconfig.properties.option2}" />
  </filterset>
</copy>

(note! I haven't actually tested this example)



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