Timothy
Gerard
diff --git a/manual/Tasks/copy.html b/manual/Tasks/copy.html
index 7e95c1d85..58218a089 100644
--- a/manual/Tasks/copy.html
+++ b/manual/Tasks/copy.html
@@ -131,6 +131,15 @@ operation as filtersets.
No; defaults to true. |
+
+ quiet |
+ If true and failonerror is false, then do not log a
+ warning message when the file to copy does not exist or one of the nested
+ filesets points to a directory that doesn't exist or an error occurs
+ while copying. since Ant 1.8.3.
+ |
+ No; defaults to false. |
+
verbose |
Log the files that are being copied. |
diff --git a/manual/Tasks/move.html b/manual/Tasks/move.html
index c24a7d823..add618af5 100644
--- a/manual/Tasks/move.html
+++ b/manual/Tasks/move.html
@@ -121,6 +121,15 @@ there is a directory by the same name in todir, the action will fail.
No; defaults to true. |
+
+ quiet |
+ If true and failonerror is false, then do not log a
+ warning message when the file to copy does not exist or one of the nested
+ filesets points to a directory that doesn't exist or an error occurs
+ while copying. since Ant 1.8.3.
+ |
+ No; defaults to false. |
+
verbose |
Log the files that are being moved. |
diff --git a/src/main/org/apache/tools/ant/taskdefs/Copy.java b/src/main/org/apache/tools/ant/taskdefs/Copy.java
index d55bf2386..72bcaba7e 100644
--- a/src/main/org/apache/tools/ant/taskdefs/Copy.java
+++ b/src/main/org/apache/tools/ant/taskdefs/Copy.java
@@ -102,6 +102,7 @@ public class Copy extends Task {
private String outputEncoding = null;
private long granularity = 0;
private boolean force = false;
+ private boolean quiet = false;
// used to store the single non-file resource to copy when the
// tofile attribute has been used
@@ -284,6 +285,18 @@ public class Copy extends Task {
this.includeEmpty = includeEmpty;
}
+ /**
+ * Set quiet mode. Used to hide messages when a file or directory to be
+ * copied does not exist.
+ *
+ * @param quiet
+ * whether or not to display error messages when a file or
+ * directory does not exist. Default is false.
+ */
+ public void setQuiet(boolean quiet) {
+ this.quiet = quiet;
+ }
+
/**
* Set method of handling mappers that return multiple
* mappings for a given source path.
@@ -480,7 +493,9 @@ public class Copy extends Task {
.DOES_NOT_EXIST_POSTFIX)) {
throw e;
} else {
- log("Warning: " + getMessage(e), Project.MSG_ERR);
+ if (!quiet) {
+ log("Warning: " + getMessage(e), Project.MSG_ERR);
+ }
continue;
}
}
@@ -509,7 +524,9 @@ public class Copy extends Task {
String message = "Warning: Could not find resource "
+ r.toLongString() + " to copy.";
if (!failonerror) {
- log(message, Project.MSG_ERR);
+ if (!quiet) {
+ log(message, Project.MSG_ERR);
+ }
} else {
throw new BuildException(message);
}
@@ -550,7 +567,9 @@ public class Copy extends Task {
doFileOperations();
} catch (BuildException e) {
if (!failonerror) {
- log("Warning: " + getMessage(e), Project.MSG_ERR);
+ if (!quiet) {
+ log("Warning: " + getMessage(e), Project.MSG_ERR);
+ }
} else {
throw e;
}
@@ -569,7 +588,9 @@ public class Copy extends Task {
doResourceOperations(map);
} catch (BuildException e) {
if (!failonerror) {
- log("Warning: " + getMessage(e), Project.MSG_ERR);
+ if (!quiet) {
+ log("Warning: " + getMessage(e), Project.MSG_ERR);
+ }
} else {
throw e;
}
@@ -615,7 +636,9 @@ public class Copy extends Task {
String message = "Warning: Could not find file "
+ file.getAbsolutePath() + " to copy.";
if (!failonerror) {
- log(message, Project.MSG_ERR);
+ if (!quiet) {
+ log(message, Project.MSG_ERR);
+ }
} else {
throw new BuildException(message);
}
diff --git a/src/tests/antunit/taskdefs/copy-test.xml b/src/tests/antunit/taskdefs/copy-test.xml
index be94552b2..6f0d5dfe1 100644
--- a/src/tests/antunit/taskdefs/copy-test.xml
+++ b/src/tests/antunit/taskdefs/copy-test.xml
@@ -241,6 +241,13 @@ public class NullByteStreamResource extends Resource {
failonerror="false"/>
+
+
+
+
+
+
+