0

I am writing an ant script that replaces all tokens in a file by getting its values from another file. For instance, the file a.properties contains tokens,

server.url=@SERVER.URL@
application.id=@APP.ID@
etc...

And the values for the tokens should be fetched from a single file, say token.properties which contains the below entries

SERVER.URL=http://localhost:80
APP.ID=HelloWorld

I want to accomplish this without mentioning the replacefilter for each token. I have tried searching in the web for this and couldn't figure out. Is this possible in ant?

Iowa
  • 2,171
  • 4
  • 22
  • 31

1 Answers1

1

Here is an example that replaces values in server.properties based on values.properties.

build.xml

<?xml version="1.0"?>
<project name="Token Replacement" default="default">

   <target name="default">
      <replace file="server.properties" replacefilterfile="values.properties"/>
   </target>

</project>

server.properties - file that needs to binded

user.firstName=$firstName 
user.lastName=$lastName
user.company=$company

values.properties - the properties from this file will be used for replacement

$firstName=John
$lastName=Doe
$company=Acme
JChap
  • 1,421
  • 9
  • 23