Browse Source

BR 41986

- add a quiet attribute to the copy task to not print warning messages
Thanks to Timoteo Ohara


git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@1150331 13f79535-47bb-0310-9956-ffa450edef68
master
Nicolas Lalevee 14 years ago
parent
commit
309943afdb
7 changed files with 62 additions and 5 deletions
  1. +1
    -0
      CONTRIBUTORS
  2. +4
    -0
      WHATSNEW
  3. +4
    -0
      contributors.xml
  4. +9
    -0
      manual/Tasks/copy.html
  5. +9
    -0
      manual/Tasks/move.html
  6. +28
    -5
      src/main/org/apache/tools/ant/taskdefs/Copy.java
  7. +7
    -0
      src/tests/antunit/taskdefs/copy-test.xml

+ 1
- 0
CONTRIBUTORS View File

@@ -341,6 +341,7 @@ Thomas Quas
Tim Drury
Tim Fennell
Tim Stephenson
Timoteo Ohara
Timothy Gerard Endres
Tom Ball
Tom Brus


+ 4
- 0
WHATSNEW View File

@@ -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:
--------------



+ 4
- 0
contributors.xml View File

@@ -1375,6 +1375,10 @@
<first>Tim</first>
<last>Fennell</last>
</name>
<name>
<first>Timoteo</first>
<last>Ohara</last>
</name>
<name>
<first>Timothy</first>
<middle>Gerard</middle>


+ 9
- 0
manual/Tasks/copy.html View File

@@ -131,6 +131,15 @@ operation as <a href="../Types/filterset.html">filtersets</a>.
</td>
<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>


+ 9
- 0
manual/Tasks/move.html View File

@@ -121,6 +121,15 @@ there is a directory by the same name in <i>todir</i>, the action will fail.
</td>
<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>


+ 28
- 5
src/main/org/apache/tools/ant/taskdefs/Copy.java View File

@@ -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);
}


+ 7
- 0
src/tests/antunit/taskdefs/copy-test.xml View File

@@ -241,6 +241,13 @@ public class NullByteStreamResource extends Resource {
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">


Loading…
Cancel
Save