You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ant.apache.org by bo...@apache.org on 2003/05/19 17:37:32 UTC
cvs commit: ant/src/main/org/apache/tools/ant/taskdefs Copy.java
bodewig 2003/05/19 08:37:31
Modified: . WHATSNEW
docs/manual/CoreTasks copy.html move.html
src/main/org/apache/tools/ant/taskdefs Copy.java
Log:
Make <copy>'s failonerror attribute swallow exception while copying as
well.
PR: 12999
Revision Changes Path
1.422 +4 -0 ant/WHATSNEW
Index: WHATSNEW
===================================================================
RCS file: /home/cvs/ant/WHATSNEW,v
retrieving revision 1.421
retrieving revision 1.422
diff -u -r1.421 -r1.422
--- WHATSNEW 19 May 2003 12:18:07 -0000 1.421
+++ WHATSNEW 19 May 2003 15:37:31 -0000 1.422
@@ -358,6 +358,10 @@
* <apply> and <chmod> will display a summary if you set the new
verbose attribute to true. Bugzilla Report 19883.
+* <copy>/<move>'s failonerror attribute can now also be used to
+ continue the build if an I/O error caused a problem. Bugzilla
+ Report 12999.
+
Changes from Ant 1.5.2 to Ant 1.5.3
===================================
1.18 +2 -1 ant/docs/manual/CoreTasks/copy.html
Index: copy.html
===================================================================
RCS file: /home/cvs/ant/docs/manual/CoreTasks/copy.html,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -r1.17 -r1.18
--- copy.html 14 May 2003 11:53:41 -0000 1.17
+++ copy.html 19 May 2003 15:37:31 -0000 1.18
@@ -95,7 +95,8 @@
<td valign="top">failonerror</td>
<td valign="top">Log a warning message, but do not stop the
build, when the file to copy does not exist or one of the nested
- filesets points to a directory that doesn't exist.
+ filesets points to a directory that doesn't exist or an error occurs
+ while copying.
</td>
<td valign="top" align="center">No; defaults to true.</td>
</tr>
1.13 +2 -1 ant/docs/manual/CoreTasks/move.html
Index: move.html
===================================================================
RCS file: /home/cvs/ant/docs/manual/CoreTasks/move.html,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -r1.12 -r1.13
--- move.html 14 May 2003 11:53:41 -0000 1.12
+++ move.html 19 May 2003 15:37:31 -0000 1.13
@@ -80,7 +80,8 @@
<td valign="top">failonerror</td>
<td valign="top">Log a warning message, but do not stop the
build, when the file to copy does not exist or one of the nested
- filesets points to a directory that doesn't exist.
+ filesets points to a directory that doesn't exist or an error occurs
+ while moving.
</td>
<td valign="top" align="center">No; defaults to true.</td>
</tr>
1.58 +56 -48 ant/src/main/org/apache/tools/ant/taskdefs/Copy.java
Index: Copy.java
===================================================================
RCS file: /home/cvs/ant/src/main/org/apache/tools/ant/taskdefs/Copy.java,v
retrieving revision 1.57
retrieving revision 1.58
diff -u -r1.57 -r1.58
--- Copy.java 19 May 2003 15:21:15 -0000 1.57
+++ Copy.java 19 May 2003 15:37:31 -0000 1.58
@@ -401,7 +401,15 @@
}
// do all the copy operations now...
- doFileOperations();
+ try {
+ doFileOperations();
+ } catch (BuildException e) {
+ if (!failonerror) {
+ log("Warning: " + e.getMessage(), Project.MSG_ERR);
+ } else {
+ throw e;
+ }
+ }
} finally {
// clean up again, so this instance can be used a second
// time
@@ -418,66 +426,66 @@
}
}
-//************************************************************************
-// protected and private methods
-//************************************************************************
-
- /**
- * Ensure we have a consistent and legal set of attributes, and set
- * any internal flags necessary based on different combinations
- * of attributes.
- */
- protected void validateAttributes() throws BuildException {
- if (file == null && filesets.size() == 0) {
- throw new BuildException("Specify at least one source "
- + "- a file or a fileset.");
- }
-
- if (destFile != null && destDir != null) {
- throw new BuildException("Only one of tofile and todir "
- + "may be set.");
- }
+ //************************************************************************
+ // protected and private methods
+ //************************************************************************
+
+ /**
+ * Ensure we have a consistent and legal set of attributes, and set
+ * any internal flags necessary based on different combinations
+ * of attributes.
+ */
+ protected void validateAttributes() throws BuildException {
+ if (file == null && filesets.size() == 0) {
+ throw new BuildException("Specify at least one source "
+ + "- a file or a fileset.");
+ }
- if (destFile == null && destDir == null) {
- throw new BuildException("One of tofile or todir must be set.");
- }
+ if (destFile != null && destDir != null) {
+ throw new BuildException("Only one of tofile and todir "
+ + "may be set.");
+ }
- if (file != null && file.exists() && file.isDirectory()) {
- throw new BuildException("Use a fileset to copy directories.");
- }
+ if (destFile == null && destDir == null) {
+ throw new BuildException("One of tofile or todir must be set.");
+ }
- if (destFile != null && filesets.size() > 0) {
- if (filesets.size() > 1) {
- throw new BuildException(
- "Cannot concatenate multiple files into a single file.");
- } else {
- FileSet fs = (FileSet) filesets.elementAt(0);
- DirectoryScanner ds = fs.getDirectoryScanner(getProject());
- String[] srcFiles = ds.getIncludedFiles();
+ if (file != null && file.exists() && file.isDirectory()) {
+ throw new BuildException("Use a fileset to copy directories.");
+ }
- if (srcFiles.length == 0) {
+ if (destFile != null && filesets.size() > 0) {
+ if (filesets.size() > 1) {
throw new BuildException(
- "Cannot perform operation from directory to file.");
- } else if (srcFiles.length == 1) {
- if (file == null) {
- file = new File(ds.getBasedir(), srcFiles[0]);
- filesets.removeElementAt(0);
+ "Cannot concatenate multiple files into a single file.");
+ } else {
+ FileSet fs = (FileSet) filesets.elementAt(0);
+ DirectoryScanner ds = fs.getDirectoryScanner(getProject());
+ String[] srcFiles = ds.getIncludedFiles();
+
+ if (srcFiles.length == 0) {
+ throw new BuildException(
+ "Cannot perform operation from directory to file.");
+ } else if (srcFiles.length == 1) {
+ if (file == null) {
+ file = new File(ds.getBasedir(), srcFiles[0]);
+ filesets.removeElementAt(0);
+ } else {
+ throw new BuildException("Cannot concatenate multiple "
+ + "files into a single file.");
+ }
} else {
throw new BuildException("Cannot concatenate multiple "
+ "files into a single file.");
}
- } else {
- throw new BuildException("Cannot concatenate multiple "
- + "files into a single file.");
}
}
- }
- if (destFile != null) {
- destDir = fileUtils.getParentFile(destFile);
- }
+ if (destFile != null) {
+ destDir = fileUtils.getParentFile(destFile);
+ }
- }
+ }
/**
* Compares source files to destination files to see if they should be