0

I'm trying to use ANT built-in (so no contrib) to create a configuration file.

What I want to do is if a property from a .properties file is set, ANT will replace the corresponding token in the configuration file.

But since I get 2 (or more) groups of properties, I first need to filter them.

For exemple :

build.properties :

test.p1=valueTestA
test.p2=valueTestB
prod.p2=valueProdA
prod.p3=valueProdB

base cfg file :

var1 = "@p1@";
var2 = "@p2@";
var3 = "@p3@";

In the end, depending if I use test or prod group of properties, only @p1@ @p2@ OR @p2@ @p3@ will be replaced (and other ignored)

I tried to use <propertyref> and <mapper> to filter but it looks like I'm doing it really wrong.

Any idea to help me to do this ?

Mr Lister
  • 45,515
  • 15
  • 108
  • 150
GdC
  • 189
  • 1
  • 1
  • 9
  • Possible duplicate of [Replacing all tokens based on properties file with ANT](http://stackoverflow.com/questions/4508122/replacing-all-tokens-based-on-properties-file-with-ant) – Chad Nouis Mar 07 '16 at 15:48

1 Answers1

1

declaring the Filter alone is not enough,

you should use something like

<filter filtersfile="build.properties"/>
<copy file="basecfgfile" tofile="${dest.file}" filtering="true" />

and in that case, mind that the token text would need to match i.e. 'p1' instead of 'prod.p1'.

Any particular reason or constraint why not to use ant-contrib?

Daniele
  • 1,053
  • 10
  • 17