The ANT task, myreplace is created within build. This task gets all the keys and iterates through each key in a foreach loop. The ANT-Contrib task that is used to get the keys is propertyselector.
This follows the standard regular expression syntax accepted by ANT's regular expression tasks. This used the substitution pattern syntax to indicate where to insert groupings created as a result of the regular expression match.
The ANT task, myreplaceeach is created within build. This task gets the value corresponding to the key provided and then iterates through each file in the specified folder yourSeachFolder and replaces the key with the value. The ANT-Contrib task that is used is propertycopy.
Before the execution of the above ANT task, the only thing you will need to confirm is your myprop. Note: If you have key-value pairs where the key is not found in the search folder during the execution, it will not stop or break the ANT execution. Object org. ProjectComponent org. Task org. MatchingTask org. Replace All Implemented Interfaces: java. Cloneable, SelectorContainer public class Replace extends MatchingTask Replaces all occurrences of one or more string tokens with given values in the indicated files.
Each value can be either a string or the value of a property available in a designated property file. NestedString An inline string to use as the replacement text. The contents of the build property file are similar to the normal java property file. They contain one property per line. Each property is represented by a name and a value pair.
It is highly recommended that the properties are annotated with proper comments. Comments are listed using the hash character. The following example shows a build.
In the above example, sitename is a custom property which is mapped to the website name. You can declare any number of custom properties in this fashion. Another custom property listed in the above example is the buildversion , which, in this instance, refers to the version of the build. In addition to the above, Ant comes with a number of predefined build properties, which are listed in the previous section, but is given below once again for your reference.
0コメント