Browse Source

New attribute for <replace> that allows all properties of a given

property file to be used as replacefilter.

PR: 7320
Submitted by:	Wolfgang.Jakel@lutzwolf.de


git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@272203 13f79535-47bb-0310-9956-ffa450edef68
master
Stefan Bodewig 23 years ago
parent
commit
1f3caa57f6
1 changed files with 21 additions and 0 deletions
  1. +21
    -0
      src/main/org/apache/tools/ant/taskdefs/Replace.java

+ 21
- 0
src/main/org/apache/tools/ant/taskdefs/Replace.java View File

@@ -72,6 +72,7 @@ import java.io.OutputStreamWriter;
import java.io.FileOutputStream;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.util.Enumeration;
import java.util.Properties;
import java.util.Vector;

@@ -92,6 +93,7 @@ public class Replace extends MatchingTask {
private NestedString value = new NestedString();

private File propertyFile = null;
private File replaceFilterFile = null;
private Properties properties = null;
private Vector replacefilters = new Vector();

@@ -207,6 +209,18 @@ public class Replace extends MatchingTask {
* Do the execution.
*/
public void execute() throws BuildException {

if (replaceFilterFile != null) {
Properties properties = getProperties(replaceFilterFile);
Enumeration enum = properties.keys();
while(enum.hasMoreElements()){
String token = enum.nextElement().toString();
Replacefilter replaceFilter = createReplacefilter();
replaceFilter.setToken(token);
replaceFilter.setValue(properties.getProperty(token));
}
}

validateAttributes();

if (propertyFile != null) {
@@ -434,6 +448,13 @@ public class Replace extends MatchingTask {
}
/**
* Sets a file used to define multiple ReplaceFilters from key-value pairs.
*/
public void setReplaceFilterFile(File filename) {
replaceFilterFile = filename;
}

/**
* Set the source files path when using matching tasks.
*/


Loading…
Cancel
Save