Author: hibou
Date: Sun Jul 24 10:35:58 2011
New Revision: 1150331
URL: http://svn.apache.org/viewvc?rev=1150331&view=rev
Log:
BR 41986
- add a quiet attribute to the copy task to not print warning messages
Thanks to Timoteo Ohara
Modified:
ant/core/trunk/CONTRIBUTORS
ant/core/trunk/WHATSNEW
ant/core/trunk/contributors.xml
ant/core/trunk/manual/Tasks/copy.html
ant/core/trunk/manual/Tasks/move.html
ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Copy.java
ant/core/trunk/src/tests/antunit/taskdefs/copy-test.xml
Modified: ant/core/trunk/CONTRIBUTORS
URL:
http://svn.apache.org/viewvc/ant/core/trunk/CONTRIBUTORS?rev=1150331&r1=1150330&r2=1150331&view=diff
==============================================================================
--- ant/core/trunk/CONTRIBUTORS (original)
+++ ant/core/trunk/CONTRIBUTORS Sun Jul 24 10:35:58 2011
@@ -341,6 +341,7 @@ Thomas Quas
Tim Drury
Tim Fennell
Tim Stephenson
+Timoteo Ohara
Timothy Gerard Endres
Tom Ball
Tom Brus
Modified: ant/core/trunk/WHATSNEW
URL:
http://svn.apache.org/viewvc/ant/core/trunk/WHATSNEW?rev=1150331&r1=1150330&r2=1150331&view=diff
==============================================================================
--- ant/core/trunk/WHATSNEW (original)
+++ ant/core/trunk/WHATSNEW Sun Jul 24 10:35:58 2011
@@ -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:
--------------
Modified: ant/core/trunk/contributors.xml
URL:
http://svn.apache.org/viewvc/ant/core/trunk/contributors.xml?rev=1150331&r1=1150330&r2=1150331&view=diff
==============================================================================
--- ant/core/trunk/contributors.xml (original)
+++ ant/core/trunk/contributors.xml Sun Jul 24 10:35:58 2011
@@ -1376,6 +1376,10 @@
<last>Fennell</last>
</name>
<name>
+ <first>Timoteo</first>
+ <last>Ohara</last>
+ </name>
+ <name>
<first>Timothy</first>
<middle>Gerard</middle>
<last>Endres</last>
Modified: ant/core/trunk/manual/Tasks/copy.html
URL:
http://svn.apache.org/viewvc/ant/core/trunk/manual/Tasks/copy.html?rev=1150331&r1=1150330&r2=1150331&view=diff
==============================================================================
--- ant/core/trunk/manual/Tasks/copy.html (original)
+++ ant/core/trunk/manual/Tasks/copy.html Sun Jul 24 10:35:58 2011
@@ -132,6 +132,15 @@ operation as <a href="../Types/filterset
<td valign="top" align="center">No; defaults to true.</td>
</tr>
<tr>
+ <td valign="top">quiet</td>
+ <td valign="top">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. <em>since Ant 1.8.3</em>.
+ </td>
+ <td valign="top" align="center">No; defaults to false.</td>
+ </tr>
+ <tr>
<td valign="top">verbose</td>
<td valign="top">Log the files that are being copied.</td>
<td valign="top" align="center">No; defaults to false.</td>
Modified: ant/core/trunk/manual/Tasks/move.html
URL:
http://svn.apache.org/viewvc/ant/core/trunk/manual/Tasks/move.html?rev=1150331&r1=1150330&r2=1150331&view=diff
==============================================================================
--- ant/core/trunk/manual/Tasks/move.html (original)
+++ ant/core/trunk/manual/Tasks/move.html Sun Jul 24 10:35:58 2011
@@ -122,6 +122,15 @@ there is a directory by the same name in
<td valign="top" align="center">No; defaults to true.</td>
</tr>
<tr>
+ <td valign="top">quiet</td>
+ <td valign="top">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. <em>since Ant 1.8.3</em>.
+ </td>
+ <td valign="top" align="center">No; defaults to false.</td>
+ </tr>
+ <tr>
<td valign="top">verbose</td>
<td valign="top">Log the files that are being moved.</td>
<td valign="top" align="center">No; defaults to false.</td>
Modified: ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Copy.java
URL:
http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Copy.java?rev=1150331&r1=1150330&r2=1150331&view=diff
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Copy.java (original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Copy.java Sun Jul 24
10:35:58 2011
@@ -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);
}
Modified: ant/core/trunk/src/tests/antunit/taskdefs/copy-test.xml
URL:
http://svn.apache.org/viewvc/ant/core/trunk/src/tests/antunit/taskdefs/copy-test.xml?rev=1150331&r1=1150330&r2=1150331&view=diff
==============================================================================
--- ant/core/trunk/src/tests/antunit/taskdefs/copy-test.xml (original)
+++ ant/core/trunk/src/tests/antunit/taskdefs/copy-test.xml Sun Jul 24 10:35:58
2011
@@ -241,6 +241,13 @@ public class NullByteStreamResource exte
failonerror="false"/>
</target>
+ <target name="testQuiet">
+ <mkdir dir="${output}"/>
+ <mkdir dir="${input}"/>
+ <copy file="${input}/not-there.txt" todir="${output}" failonerror="false"
quiet="true" />
+ <au:assertLogDoesntContain text="Could not find file" />
+ </target>
+
<target name="testMissingFilesetRoot">
<mkdir dir="${output}"/>
<au:expectfailure expectedMessage="does not exist">