org.apache.tools.ant.taskdefs
public class Copy extends Task
This implementation is based on Arnout Kuiper's initial design document, the following mailing list discussions, and the copyfile/copydir tasks.
Since: Ant 1.2
UNKNOWN: category="filesystem"
Field Summary | |
---|---|
protected Hashtable | completeDirMap |
protected File | destDir |
protected File | destFile |
protected Hashtable | dirCopyMap |
protected boolean | failonerror |
protected File | file |
protected Hashtable | fileCopyMap |
protected Vector | filesets |
protected FileUtils | fileUtils |
protected boolean | filtering |
protected boolean | flatten |
protected boolean | forceOverwrite |
protected boolean | includeEmpty |
protected Mapper | mapperElement |
protected boolean | preserveLastModified |
protected int | verbosity |
Constructor Summary | |
---|---|
Copy()
Copy task constructor. |
Method Summary | |
---|---|
void | add(FileNameMapper fileNameMapper)
A nested filenamemapper |
void | addFileset(FileSet set)
Adds a set of files to copy. |
protected void | buildMap(File fromDir, File toDir, String[] names, FileNameMapper mapper, Hashtable map)
Add to a map of files/directories to copy
|
FilterChain | createFilterChain()
Adds a FilterChain. |
FilterSet | createFilterSet()
Adds a filterset. |
Mapper | createMapper()
Defines the mapper to map source to destination files. |
protected void | doFileOperations()
Actually does the file (and possibly empty directory) copies.
|
void | execute()
Performs the copy operation. |
String | getEncoding() |
protected FileUtils | getFileUtils() |
protected Vector | getFilterChains()
Get the filterchains being applied to this operation.
|
protected Vector | getFilterSets()
Get the filtersets being applied to this operation.
|
String | getOutputEncoding() |
boolean | getPreserveLastModified()
Whether to give the copied files the same last modified time as
the original files. |
boolean | isEnableMultipleMapping() |
protected void | scan(File fromDir, File toDir, String[] files, String[] dirs)
Compares source files to destination files to see if they should be
copied.
|
void | setEnableMultipleMappings(boolean enableMultipleMappings)
Attribute to handle mappers that return multiple
mappings for a given source path. |
void | setEncoding(String encoding)
Sets the character encoding |
void | setFailOnError(boolean failonerror)
If false, note errors to the output but keep going. |
void | setFile(File file)
Sets a single source file to copy. |
void | setFiltering(boolean filtering)
If true, enables filtering. |
void | setFlatten(boolean flatten)
When copying directory trees, the files can be "flattened"
into a single directory. |
void | setGranularity(long granularity)
The number of milliseconds leeway to give before deciding a
target is out of date.
|
void | setIncludeEmptyDirs(boolean includeEmpty)
Used to copy empty directories. |
void | setOutputEncoding(String encoding)
Sets the character encoding for output files. |
void | setOverwrite(boolean overwrite)
Overwrite any existing destination file(s). |
void | setPreserveLastModified(String preserve)
Give the copied files the same last modified time as the original files. |
void | setPreserveLastModified(boolean preserve)
Give the copied files the same last modified time as the original files. |
void | setTodir(File destDir)
Sets the destination directory. |
void | setTofile(File destFile)
Sets the destination file. |
void | setVerbose(boolean verbose)
Used to force listing of all names of copied files. |
protected void | validateAttributes()
Ensure we have a consistent and legal set of attributes, and set
any internal flags necessary based on different combinations
of attributes. |
Parameters: fileNameMapper the mapper to add
Since: Ant 1.6.3
Parameters: set a set of files to copy
Parameters: fromDir the source directory toDir the destination directory names a list of filenames mapper a FileNameMapper
value map a map of source file to array of destination files
Returns: a filter chain object
Returns: a filter set object
Returns: a mapper to be configured
Throws: BuildException if more than one mapper is defined
Throws: BuildException if an error occurs
Returns: the character encoding, null
if not set.
Since: 1.32, Ant 1.5
Returns: the fileutils object
Returns: a vector of FilterChain objects
Returns: a vector of FilterSet objects
Returns: the character encoding for output files,
null
if not set.
Since: Ant 1.6
Returns: the preserveLastModified attribute
Since: 1.32, Ant 1.5
Returns: the value of the enableMultipleMapping attribute
Parameters: fromDir The source directory toDir The destination directory files A list of files to copy dirs A list of directories to copy
Parameters: enableMultipleMappings If true the task will copy to all the mappings for a given source path, if false, only the first file or directory is processed. By default, this setting is false to provide backward compatibility with earlier releases.
Since: 1.6
Parameters: encoding the character encoding
Since: 1.32, Ant 1.5
Parameters: failonerror true or false
Parameters: file the file to copy
Parameters: filtering if true enable filtering, default is false
Parameters: flatten if true flatten the destination directory. Default is false.
Default is 0 milliseconds, or 2 seconds on DOS systems.
Since: Ant 1.6.2
Parameters: includeEmpty if true copy empty directories. Default is true.
Parameters: encoding the character encoding
Since: Ant 1.6
Parameters: overwrite if true force overwriting of destination file(s) even if the destination file(s) are younger than the corresponding source file. Default is false.
Deprecated: setPreserveLastModified(String) has been deprecated and replaced with setPreserveLastModified(boolean) to consistently let the Introspection mechanism work.
Give the copied files the same last modified time as the original files.Parameters: preserve a boolean string
Parameters: preserve if true perverse the modified time, default is false
Parameters: destDir the destination directory
Parameters: destFile the file to copy to
Parameters: verbose output the names of copied files. Default is false.
Throws: BuildException if an error occurs