diff --git a/CONTRIBUTORS b/CONTRIBUTORS index f9539b9b8..fb165f825 100644 --- a/CONTRIBUTORS +++ b/CONTRIBUTORS @@ -341,6 +341,7 @@ Thomas Quas Tim Drury Tim Fennell Tim Stephenson +Timoteo Ohara Timothy Gerard Endres Tom Ball Tom Brus diff --git a/WHATSNEW b/WHATSNEW index 5c1eaec42..3c3901c5f 100644 --- a/WHATSNEW +++ b/WHATSNEW @@ -59,6 +59,10 @@ Fixed bugs: OutOfMemoryException while unzipping large archives. Bugzilla Report 42969. + * quiet attribute added to the copy and move tasks, to be used together + with failonerror=true, so warnings won't get logged + Bugzilla Report 48789. + Other changes: -------------- diff --git a/contributors.xml b/contributors.xml index 632864323..94197c71e 100644 --- a/contributors.xml +++ b/contributors.xml @@ -1375,6 +1375,10 @@ Tim Fennell + + Timoteo + Ohara + 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"/> + + + + + + +