Methods Summary |
---|
public void | execute()Execute the task.
log("DEPRECATED - The copydir task is deprecated. Use copy instead.");
if (srcDir == null) {
throw new BuildException("src attribute must be set!",
getLocation());
}
if (!srcDir.exists()) {
throw new BuildException("srcdir " + srcDir.toString()
+ " does not exist!", getLocation());
}
if (destDir == null) {
throw new BuildException("The dest attribute must be set.",
getLocation());
}
if (srcDir.equals(destDir)) {
log("Warning: src == dest", Project.MSG_WARN);
}
DirectoryScanner ds = super.getDirectoryScanner(srcDir);
try {
String[] files = ds.getIncludedFiles();
scanDir(srcDir, destDir, files);
if (filecopyList.size() > 0) {
log("Copying " + filecopyList.size() + " file"
+ (filecopyList.size() == 1 ? "" : "s")
+ " to " + destDir.getAbsolutePath());
Enumeration e = filecopyList.keys();
while (e.hasMoreElements()) {
String fromFile = (String) e.nextElement();
String toFile = (String) filecopyList.get(fromFile);
try {
getProject().copyFile(fromFile, toFile, filtering,
forceOverwrite);
} catch (IOException ioe) {
String msg = "Failed to copy " + fromFile + " to "
+ toFile + " due to " + ioe.getMessage();
throw new BuildException(msg, ioe, getLocation());
}
}
}
} finally {
filecopyList.clear();
}
|
private void | scanDir(java.io.File from, java.io.File to, java.lang.String[] files)
for (int i = 0; i < files.length; i++) {
String filename = files[i];
File srcFile = new File(from, filename);
File destFile;
if (flatten) {
destFile = new File(to, new File(filename).getName());
} else {
destFile = new File(to, filename);
}
if (forceOverwrite
|| (srcFile.lastModified() > destFile.lastModified())) {
filecopyList.put(srcFile.getAbsolutePath(),
destFile.getAbsolutePath());
}
}
|
public void | setDest(java.io.File dest)The dest attribute
destDir = dest;
|
public void | setFiltering(boolean filter)The filtering attribute.
Default is false.
filtering = filter;
|
public void | setFlatten(boolean flatten)The flattening attribute.
Default is false.
this.flatten = flatten;
|
public void | setForceoverwrite(boolean force)The forceoverwrite attribute.
Default is false.
forceOverwrite = force;
|
public void | setSrc(java.io.File src)The src attribute
srcDir = src;
|