diff --git a/docs/manual/CoreTasks/copy.html b/docs/manual/CoreTasks/copy.html index 80a9bcba5..bb9e87b80 100644 --- a/docs/manual/CoreTasks/copy.html +++ b/docs/manual/CoreTasks/copy.html @@ -9,12 +9,14 @@

Copy

Description

-

Copies a file or Fileset to a new file or directory. Files are +

Copies a file or FileSet to a new file or directory. By default, files are only copied if the source file is newer than the destination file, or when the destination file does not exist. However, you can explicitly -overwrite files with the overwrite attribute.

-

FileSets are used to select files to copy. -To use a fileset, the todir attribute must be set.

+overwrite files with the overwrite attribute.

+

FileSets are used to select a +set of files to copy. +To use a <fileset>, the todir attribute +must be set.

Parameters

@@ -25,24 +27,26 @@ To use a fileset, the todir attribute must be set.

- + - + time as the original source files. + (Note: Ignored on Java 1.1) + - + @@ -51,46 +55,58 @@ To use a fileset, the todir attribute must be set.

- + files are newer. + - - + + - - + + - - + + + + + + +
file The file to copy.One of either file or - at least one nested fileset element.Yes, unless a nested + <fileset> element is used.
preservelastmodified Give the copied files the same last modified - time as the original source files. Defaults to "no". - [ignored on Java 1.1]NoNo; defaults to false.
tofile The file to copy to.With the file attribute, - either tofile or todir can be used. With nested filesets, - if the fileset size is greater than 1 or if the only entry in the fileset is a - directory or if the file attribute is already specified, only - todir is allowedWith the file + attribute, either tofile or todir can be used. + With nested <fileset> elements, if the set of files + is greater than 1, or if only the dir attribute is + specified in the <fileset>, or if the + file attribute is also specified, then only + todir is allowed.
todir
overwrite Overwrite existing files even if the destination - files are newer. Defaults to "no".NoNo; defaults to false.
filteringIndicates whether token filtering using the global build file - filters should take place during the copy. Defaults to "no". - Nested filtersets will be used even if this value is "no"NoIndicates whether token filtering using the global + build-file filters should take place during the copy. + Note: Nested <filterset> elements will + always be used, even if this attribute is not specified, or its value is + false (no, or off).No; defaults to false.
flattenIgnore directory structure of source directory, - copy all files into a single directory, specified by the todir - attribute. Defaults to "no". Note that you can achieve the - same effect by using a flatten mapperNoIgnore the directory structure of the source files, + and copy all files into the directory specified by the todir + attribute. Note that you can achieve the same effect by using a + flatten mapper.No; defaults to false.
includeEmptyDirsCopy empty directories included with the nested FileSet(s). - Defaults to "yes".NoCopy any empty directories included in the FileSet(s). + No; defaults to true.
failonerrorLog a warning message, but do not stop the build, + when the file to copy does not exist. + Only meaningful when copying a single file. + No; defaults to true.

Parameters specified as nested elements

fileset

-

FileSets are used to select files to copy. - To use a fileset, the todir attribute must be set.

+

FileSets are used to select +sets of files to copy. + To use a fileset, the todir attribute must be set.

mapper

-

You can define file name transformations by using a nested You can define filename transformations by using a nested mapper element. The default mapper used by <copy> is the identity.

+ href="../CoreTypes/mapper.html#identity-mapper">identity mapper.

filterset

-

Filtersets are used to replace tokens in files that are copied. - To use a filterset just add the nested filterset elements.

+

FilterSets are used to replace +tokens in files that are copied. + To use a FilterSet, use the nested <filterset> element.

Examples

@@ -98,9 +114,9 @@ To use a fileset, the todir attribute must be set.

   <copy file="myfile.txt" tofile="mycopy.txt"/>
 
-

Copy a file to a directory

+

Copy a single file to a directory

-  <copy file="myfile.txt" todir="../some/dir/tree"/>
+  <copy file="myfile.txt" todir="../some/other/dir"/>
 

Copy a directory to another directory

@@ -120,8 +136,8 @@ To use a fileset, the todir attribute must be set.

<fileset dir="src_dir" excludes="**/*.java"/> </copy>
-

Copy a set of files to a directory appending -".bak" to the file name on the fly

+

Copy a set of files to a directory, appending +.bak to the file name on the fly

   <copy todir="../backup/dir" >
     <fileset dir="src_dir" />
@@ -130,7 +146,8 @@ To use a fileset, the todir attribute must be set.

-

Copy a set of files to a replacing @TITLE@ with Foo Bar in all files.

+

Copy a set of files to a directory, replacing @TITLE@ with Foo Bar +in all files.

   <copy todir="../backup/dir" >
     <fileset dir="src_dir" />
@@ -140,14 +157,14 @@ To use a fileset, the todir attribute must be set.

</copy>
-

Unix Note: file permissions are not retained when files +

Unix Note: File permissions are not retained when files are copied; they end up with the default UMASK permissions instead. This is caused by the lack of any means to query or set file permissions in the -current Java runtimes. If you need a permission preserving copy function, +current Java runtimes. If you need a permission-preserving copy function, use <exec executable="cp" ... > instead. -


Copyright © 2001 Apache Software Foundation. All rights -Reserved.

+

Copyright © 2001,2002 Apache Software Foundation. +All rights Reserved.

diff --git a/src/main/org/apache/tools/ant/taskdefs/Copy.java b/src/main/org/apache/tools/ant/taskdefs/Copy.java index 7fb4c7cdf..3cae81ff5 100644 --- a/src/main/org/apache/tools/ant/taskdefs/Copy.java +++ b/src/main/org/apache/tools/ant/taskdefs/Copy.java @@ -106,6 +106,7 @@ public class Copy extends Task { protected boolean flatten = false; protected int verbosity = Project.MSG_VERBOSE; protected boolean includeEmpty = true; + private boolean failonerror = true; protected Hashtable fileCopyMap = new Hashtable(); protected Hashtable dirCopyMap = new Hashtable(); @@ -250,6 +251,14 @@ public class Copy extends Task { this.includeEmpty = includeEmpty; } + /** + * Note errors to the output, but keep going + * @param failonerror true or false + */ + public void setFailOnError(boolean failonerror) { + this.failonerror=failonerror; + } + /** * Adds a set of files (nested fileset attribute). */ @@ -309,10 +318,13 @@ public class Copy extends Task { Project.MSG_VERBOSE); } } else { - String message = "Could not find file " + String message = "Warning: Could not find file " + file.getAbsolutePath() + " to copy."; - log(message); - throw new BuildException(message); + if(!failonerror) { + log(message); + } else { + throw new BuildException(message); + } } }