HydTech
HydTech

Reputation: 49

Replacing value in text file using ant script

I have the following in a text file

BuildVersion:R2 TestVersion:1000 AndroidVersion:6.0

and I need to Change "TestVersion" value dynamically using ant script?? Please advise,

Upvotes: 2

Views: 5680

Answers (1)

Atul
Atul

Reputation: 1566

Use a placeholder for "TestVersion" and replace it during the build process. Your text file will look like this:

BuildVersion:R2 @@TestVersion@@:1000 AndroidVersion:6.0

and your ant file will contain the following target element to replace @@TestVersion@@ with some other value:

<target name="replaceTestVersion">
    <replace file="YOUR_FILE">
        <replacefilter token="@@TestVersion@@" value="YOUR_NEW_VALUE" />
    </replace>
</target>

Upvotes: 5

Related Questions