Using ant with build configuration files

antbuild-automation

I am trying to customize my build by using a configuration file with ant. What I intend to do is that use config file which has the following pattern:
file path, pattern to match, pattern to replace

I want it such that I just add things to the configuration file and the ant build script reads up these values and makes the required changes.

I already know how to do a regex find and replace in files. What I am looking for is a way to read the values from such a configration file.

Best Solution

There are various ways to read information from a file in Ant.

The generic one is the LoadFile Ant Task. I would however recommend the loadProperties Task. You could use this task to read properties such as: toReplace=string_to_replace with=replacement_string and then use the properties "toReplace" and "with" in your regexes.

Related Question