diff --git a/src/main/org/apache/tools/ant/taskdefs/Replace.java b/src/main/org/apache/tools/ant/taskdefs/Replace.java
index 7d59898e8..ae9a1fc8c 100644
--- a/src/main/org/apache/tools/ant/taskdefs/Replace.java
+++ b/src/main/org/apache/tools/ant/taskdefs/Replace.java
@@ -60,36 +60,65 @@ import java.util.*;
/**
* Replaces all the occurrences of the given string token with the given
- * string value of the indicated file.
+ * string value of the indicated files.
*
* @author Stefano Mazzocchi stefano@apache.org
*/
-public class Replace extends Task {
+public class Replace extends MatchingTask {
private File src = null;
- private File dest = null;
private String token = null;
private String value = "";
+
+ private File dir = null;
/**
* Do the execution.
*/
public void execute() throws BuildException {
- project.log("Replacing " + token + " --> " + value);
+ if (token == null) {
+ throw new BuildException("replace token must not be null");
+ }
+
+ if (src == null && dir == null) {
+ throw new BuildException("Either the file or the dir attribute must be specified");
+ }
- if (src == null || token == null ) {
- project.log("File and token must not be null");
- return;
+ project.log("Replacing " + token + " --> " + value);
+
+ if (src != null) {
+ processFile(src);
}
- if (dest == null) {
- throw new BuildException("Error creating temp file.");
+ if (dir != null) {
+ DirectoryScanner ds = super.getDirectoryScanner(dir);
+ String[] srcs = ds.getIncludedFiles();
+
+ for(int i=0; i