@@ -129,12 +129,16 @@ public class Copy extends Task {
fileUtils = FileUtils.newFileUtils();
fileUtils = FileUtils.newFileUtils();
}
}
/**
* @return the fileutils object
*/
protected FileUtils getFileUtils() {
protected FileUtils getFileUtils() {
return fileUtils;
return fileUtils;
}
}
/**
/**
* Sets a single source file to copy.
* Sets a single source file to copy.
* @param file the file to copy
*/
*/
public void setFile(File file) {
public void setFile(File file) {
this.file = file;
this.file = file;
@@ -142,6 +146,7 @@ public class Copy extends Task {
/**
/**
* Sets the destination file.
* Sets the destination file.
* @param destFile the file to copy to
*/
*/
public void setTofile(File destFile) {
public void setTofile(File destFile) {
this.destFile = destFile;
this.destFile = destFile;
@@ -149,6 +154,7 @@ public class Copy extends Task {
/**
/**
* Sets the destination directory.
* Sets the destination directory.
* @param destDir the destination directory
*/
*/
public void setTodir(File destDir) {
public void setTodir(File destDir) {
this.destDir = destDir;
this.destDir = destDir;
@@ -156,6 +162,7 @@ public class Copy extends Task {
/**
/**
* Adds a FilterChain.
* Adds a FilterChain.
* @return a filter chain object
*/
*/
public FilterChain createFilterChain() {
public FilterChain createFilterChain() {
FilterChain filterChain = new FilterChain();
FilterChain filterChain = new FilterChain();
@@ -165,6 +172,7 @@ public class Copy extends Task {
/**
/**
* Adds a filterset.
* Adds a filterset.
* @return a filter set object
*/
*/
public FilterSet createFilterSet() {
public FilterSet createFilterSet() {
FilterSet filterSet = new FilterSet();
FilterSet filterSet = new FilterSet();
@@ -174,6 +182,7 @@ public class Copy extends Task {
/**
/**
* Give the copied files the same last modified time as the original files.
* Give the copied files the same last modified time as the original files.
* @param preserve a boolean string
* @deprecated setPreserveLastModified(String) has been deprecated and
* @deprecated setPreserveLastModified(String) has been deprecated and
* replaced with setPreserveLastModified(boolean) to
* replaced with setPreserveLastModified(boolean) to
* consistently let the Introspection mechanism work.
* consistently let the Introspection mechanism work.
@@ -184,6 +193,7 @@ public class Copy extends Task {
/**
/**
* Give the copied files the same last modified time as the original files.
* Give the copied files the same last modified time as the original files.
* @param preserve if true perserce the modified time, default is false
*/
*/
public void setPreserveLastModified(boolean preserve) {
public void setPreserveLastModified(boolean preserve) {
preserveLastModified = preserve;
preserveLastModified = preserve;
@@ -192,7 +202,7 @@ public class Copy extends Task {
/**
/**
* Whether to give the copied files the same last modified time as
* Whether to give the copied files the same last modified time as
* the original files.
* the original files.
*
* @return the preserveLastModified attribute
* @since 1.32, Ant 1.5
* @since 1.32, Ant 1.5
*/
*/
public boolean getPreserveLastModified() {
public boolean getPreserveLastModified() {
@@ -219,6 +229,7 @@ public class Copy extends Task {
/**
/**
* If true, enables filtering.
* If true, enables filtering.
* @param filtering if true enable filtering, default is false
*/
*/
public void setFiltering(boolean filtering) {
public void setFiltering(boolean filtering) {
this.filtering = filtering;
this.filtering = filtering;
@@ -226,6 +237,9 @@ public class Copy extends Task {
/**
/**
* Overwrite any existing destination file(s).
* Overwrite any existing destination file(s).
* @param 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.
*/
*/
public void setOverwrite(boolean overwrite) {
public void setOverwrite(boolean overwrite) {
this.forceOverwrite = overwrite;
this.forceOverwrite = overwrite;
@@ -237,6 +251,8 @@ public class Copy extends Task {
* the same name in the source directory tree, only the first
* the same name in the source directory tree, only the first
* file will be copied into the "flattened" directory, unless
* file will be copied into the "flattened" directory, unless
* the forceoverwrite attribute is true.
* the forceoverwrite attribute is true.
* @param flatten if true flatten the destination directory. Default
* is false.
*/
*/
public void setFlatten(boolean flatten) {
public void setFlatten(boolean flatten) {
this.flatten = flatten;
this.flatten = flatten;
@@ -244,6 +260,7 @@ public class Copy extends Task {
/**
/**
* Used to force listing of all names of copied files.
* Used to force listing of all names of copied files.
* @param verbose output the names of copied files. Default is false.
*/
*/
public void setVerbose(boolean verbose) {
public void setVerbose(boolean verbose) {
if (verbose) {
if (verbose) {
@@ -255,6 +272,7 @@ public class Copy extends Task {
/**
/**
* Used to copy empty directories.
* Used to copy empty directories.
* @param includeEmpty if true copy empty directories. Default is true.
*/
*/
public void setIncludeEmptyDirs(boolean includeEmpty) {
public void setIncludeEmptyDirs(boolean includeEmpty) {
this.includeEmpty = includeEmpty;
this.includeEmpty = includeEmpty;
@@ -281,7 +299,7 @@ public class Copy extends Task {
public boolean isEnableMultipleMapping() {
public boolean isEnableMultipleMapping() {
return enableMultipleMappings;
return enableMultipleMappings;
}
}
/**
/**
* If false, note errors to the output but keep going.
* If false, note errors to the output but keep going.
* @param failonerror true or false
* @param failonerror true or false
@@ -292,6 +310,7 @@ public class Copy extends Task {
/**
/**
* Adds a set of files to copy.
* Adds a set of files to copy.
* @param set a set of files to copy
*/
*/
public void addFileset(FileSet set) {
public void addFileset(FileSet set) {
filesets.addElement(set);
filesets.addElement(set);
@@ -299,6 +318,8 @@ public class Copy extends Task {
/**
/**
* Defines the mapper to map source to destination files.
* Defines the mapper to map source to destination files.
* @return a mapper to be configured
* @exception BuildException if more than one mapper is defined
*/
*/
public Mapper createMapper() throws BuildException {
public Mapper createMapper() throws BuildException {
if (mapperElement != null) {
if (mapperElement != null) {
@@ -311,10 +332,10 @@ public class Copy extends Task {
/**
/**
* Sets the character encoding
* Sets the character encoding
*
* @param encoding the character encoding
* @since 1.32, Ant 1.5
* @since 1.32, Ant 1.5
*/
*/
public void setEncoding (String encoding) {
public void setEncoding(String encoding) {
this.inputEncoding = encoding;
this.inputEncoding = encoding;
if (outputEncoding == null) {
if (outputEncoding == null) {
outputEncoding = encoding;
outputEncoding = encoding;
@@ -332,7 +353,7 @@ public class Copy extends Task {
/**
/**
* Sets the character encoding for output files.
* Sets the character encoding for output files.
*
* @param encoding the character encoding
* @since Ant 1.6
* @since Ant 1.6
*/
*/
public void setOutputEncoding(String encoding) {
public void setOutputEncoding(String encoding) {
@@ -351,6 +372,7 @@ public class Copy extends Task {
/**
/**
* Performs the copy operation.
* Performs the copy operation.
* @exception BuildException if an error occurs
*/
*/
public void execute() throws BuildException {
public void execute() throws BuildException {
File savedFile = file; // may be altered in validateAttributes
File savedFile = file; // may be altered in validateAttributes
@@ -456,6 +478,7 @@ public class Copy extends Task {
* Ensure we have a consistent and legal set of attributes, and set
* Ensure we have a consistent and legal set of attributes, and set
* any internal flags necessary based on different combinations
* any internal flags necessary based on different combinations
* of attributes.
* of attributes.
* @exception BuildException if an error occurs
*/
*/
protected void validateAttributes() throws BuildException {
protected void validateAttributes() throws BuildException {
if (file == null && filesets.size() == 0) {
if (file == null && filesets.size() == 0) {
@@ -512,6 +535,11 @@ public class Copy extends Task {
/**
/**
* Compares source files to destination files to see if they should be
* Compares source files to destination files to see if they should be
* copied.
* copied.
*
* @param fromDir The source directory
* @param toDir The destination dirctory
* @param files A list of files to copy
* @param dirs A list of directories to copy
*/
*/
protected void scan(File fromDir, File toDir, String[] files,
protected void scan(File fromDir, File toDir, String[] files,
String[] dirs) {
String[] dirs) {
@@ -531,6 +559,15 @@ public class Copy extends Task {
}
}
}
}
/**
* Add to a map of files/directories to copy
*
* @param fromDir the source directory
* @param toDir the destination directory
* @param names a list of filenames
* @param mapper a <code>FileNameMapper</code> value
* @param map a map of source file to array of destination files
*/
protected void buildMap(File fromDir, File toDir, String[] names,
protected void buildMap(File fromDir, File toDir, String[] names,
FileNameMapper mapper, Hashtable map) {
FileNameMapper mapper, Hashtable map) {