diff --git a/build.xml b/build.xml
index 0ac15d8a6..3f93b5e2e 100644
--- a/build.xml
+++ b/build.xml
@@ -81,6 +81,7 @@
diff --git a/src/main/org/apache/tools/ant/Project.java b/src/main/org/apache/tools/ant/Project.java
index f1da629aa..b28b5be5e 100644
--- a/src/main/org/apache/tools/ant/Project.java
+++ b/src/main/org/apache/tools/ant/Project.java
@@ -558,6 +558,19 @@ public class Project {
copyFile(new File(sourceFile), new File(destFile), filtering);
}
+ /**
+ * Convienence method to copy a file from a source to a
+ * destination specifying if token filtering must be used and if
+ * source files may overwrite newer destination files.
+ *
+ * @throws IOException
+ */
+ public void copyFile(String sourceFile, String destFile, boolean filtering,
+ boolean overwrite) throws IOException {
+ copyFile(new File(sourceFile), new File(destFile), filtering,
+ overwrite);
+ }
+
/**
* Convienence method to copy a file from a source to a destination.
* No filtering is performed.
@@ -577,8 +590,21 @@ public class Project {
public void copyFile(File sourceFile, File destFile, boolean filtering)
throws IOException
{
+ copyFile(sourceFile, destFile, filtering, false);
+ }
+
+ /**
+ * Convienence method to copy a file from a source to a
+ * destination specifying if token filtering must be used and if
+ * source files may overwrite newer destination files.
+ *
+ * @throws IOException
+ */
+ public void copyFile(File sourceFile, File destFile, boolean filtering,
+ boolean overwrite) throws IOException {
- if (destFile.lastModified() < sourceFile.lastModified()) {
+ if (overwrite ||
+ destFile.lastModified() < sourceFile.lastModified()) {
log("Copy: " + sourceFile.getAbsolutePath() + " > "
+ destFile.getAbsolutePath(), MSG_VERBOSE);
diff --git a/src/main/org/apache/tools/ant/taskdefs/Copydir.java b/src/main/org/apache/tools/ant/taskdefs/Copydir.java
index ea8511754..830491714 100644
--- a/src/main/org/apache/tools/ant/taskdefs/Copydir.java
+++ b/src/main/org/apache/tools/ant/taskdefs/Copydir.java
@@ -112,7 +112,8 @@ public class Copydir extends MatchingTask {
String fromFile = (String) enum.nextElement();
String toFile = (String) filecopyList.get(fromFile);
try {
- project.copyFile(fromFile, toFile, filtering);
+ project.copyFile(fromFile, toFile, filtering,
+ forceOverwrite);
} catch (IOException ioe) {
String msg = "Failed to copy " + fromFile + " to " + toFile
+ " due to " + ioe.getMessage();
@@ -130,7 +131,7 @@ public class Copydir extends MatchingTask {
if (forceOverwrite ||
(srcFile.lastModified() > destFile.lastModified())) {
filecopyList.put(srcFile.getAbsolutePath(),
- destFile.getAbsolutePath());
+ destFile.getAbsolutePath());
}
}
}