How to overwrite the values in a properties file containing key value pair using ANT macro?

120 views Asked by At

I have two properties files

File 1 : Template.properties

  1. k1=v1
  2. k2=v2
  3. k3=v3
  4. k4=v4
  5. k5=v5

File 2 : New.properties

  1. k1=v11
  2. k2=v22
  3. k3=v33
  4. k4=v44
  5. k5=v55
  6. k6=v66
  7. k7=v77

I want to overwrite values of Template.properties with the values of New.properties and I don't want k6 and k7 in Template. How can i achieve this using ANT macro?

Please help.

1

There are 1 answers

0
Stavr00 On

Use a copy task with a filterset. The template file should have @ around the replaceable values:

k1=@v1@
k2=@v2@
k3=@v3@
k4=@v4@
k5=@v5@

The use the filterset as follows

<filterset>
  <filter token="v1" value="v11"/>
   . . . 
</filterset>