bodewig 2003/03/27 23:51:11
Modified: . WHATSNEW
src/main/org/apache/tools/ant/taskdefs Copy.java
Log:
<copy> and <move>'s failonerror didn't apply to filesets pointing to
non-existant directories.
PR: 18414.
Revision Changes Path
1.377 +3 -0 ant/WHATSNEW
Index: WHATSNEW
===================================================================
RCS file: /home/cvs/ant/WHATSNEW,v
retrieving revision 1.376
retrieving revision 1.377
diff -u -r1.376 -r1.377
--- WHATSNEW 28 Mar 2003 06:53:39 -0000 1.376
+++ WHATSNEW 28 Mar 2003 07:51:10 -0000 1.377
@@ -75,6 +75,9 @@
* The Unix wrapper script failed if you invoked it as a relative
symlink and ANT_HOME has not been set. Bugzilla Report 17721.
+* <copy> and <move>'s failonerror didn't apply to filesets pointing to
+ non-existant directories. Bugzilla Report 18414.
+
Other changes:
--------------
* Shipped XML parser is now Xerces 2.4.0
1.54 +64 -52 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.53
retrieving revision 1.54
diff -u -r1.53 -r1.54
--- Copy.java 27 Mar 2003 16:32:18 -0000 1.53
+++ Copy.java 28 Mar 2003 07:51:11 -0000 1.54
@@ -263,9 +263,9 @@
* If false, note errors to the output but keep going.
* @param failonerror true or false
*/
- public void setFailOnError(boolean failonerror) {
- this.failonerror = failonerror;
- }
+ public void setFailOnError(boolean failonerror) {
+ this.failonerror = failonerror;
+ }
/**
* Adds a set of files to copy.
@@ -374,7 +374,19 @@
// deal with the filesets
for (int i = 0; i < filesets.size(); i++) {
FileSet fs = (FileSet) filesets.elementAt(i);
- DirectoryScanner ds = fs.getDirectoryScanner(getProject());
+ DirectoryScanner ds = null;
+ try {
+ ds = fs.getDirectoryScanner(getProject());
+ } catch (BuildException e) {
+ if (failonerror
+ || !e.getMessage().endsWith(" not found.")) {
+ throw e;
+ } else {
+ log("Warning: " + e.getMessage());
+ continue;
+ }
+ }
+
File fromDir = fs.getDir(getProject());
String[] srcFiles = ds.getIncludedFiles();
@@ -405,66 +417,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