Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using Ant to merge two different properties files

I have a default properties file, and some deployment specific properties files that override certain settings from the default, based on deployment environment. I would like my Ant build script to merge the two properties files (overwriting default values with deployment specific values), and then output the resulting properties to a new file.

I tried doing it like so but I was unsuccessful:

<target depends="init" name="configure-target-environment">
    <filterset id="application-properties-filterset">
        <filtersfile file="${build.config.path}/${target.environment}/application.properties" />
    </filterset>

    <copy todir="${web-inf.path}/conf" file="${build.config.path}/application.properties" overwrite="true" failonerror="true" >
        <filterset refid="application-properties-filterset" />
    </copy>
</target>
like image 303
Justin Avatar asked Feb 02 '23 23:02

Justin


2 Answers

I did it like this:

<property prefix="app.properties" file="custom.application.properties" />
<property prefix="app.properties" file="default.application.properties" />
<echoproperties destfile="application.properties">
   <propertyset>
      <propertyref prefix="app.properties"/>
      <mapper type="glob" from="app.properties.*" to="*"/>
   </propertyset>
</echoproperties>
like image 144
LifeIsGoodMF Avatar answered Feb 08 '23 16:02

LifeIsGoodMF


Perhaps you should look at the concat task of ant for this.

like image 22
Raghuram Avatar answered Feb 08 '23 15:02

Raghuram