Methods Summary |
---|
public void | add(org.apache.tools.ant.util.FileNameMapper newmapper)add a mapper
if (mapper != null) {
throw new BuildException("Only one mapper allowed");
}
mapper = newmapper;
|
public org.apache.tools.ant.types.Path | createPath()Create a path.
if (path == null) {
path = new Path(getProject());
}
return path;
|
public void | execute()This is a very minimal derivative of the nomal copy logic.
validateAttributes();
String[] sourceFiles = path.list();
if (sourceFiles.length == 0) {
log("Path is empty", Project.MSG_VERBOSE);
return;
}
for (int sources = 0; sources < sourceFiles.length; sources++) {
String sourceFileName = sourceFiles[sources];
File sourceFile = new File(sourceFileName);
String[] toFiles = (String[]) mapper.mapFileName(sourceFileName);
for (int i = 0; i < toFiles.length; i++) {
String destFileName = toFiles[i];
File destFile = new File(destDir, destFileName);
if (sourceFile.equals(destFile)) {
log("Skipping self-copy of " + sourceFileName, Project.MSG_VERBOSE);
continue;
}
if (sourceFile.isDirectory()) {
log("Skipping directory " + sourceFileName);
continue;
}
try {
log("Copying " + sourceFile + " to " + destFile, Project.MSG_VERBOSE);
FILE_UTILS.copyFile(sourceFile, destFile, null, null, false,
preserveLastModified, null, null, getProject());
} catch (IOException ioe) {
String msg = "Failed to copy " + sourceFile + " to " + destFile + " due to "
+ ioe.getMessage();
if (destFile.exists() && !destFile.delete()) {
msg += " and I couldn't delete the corrupt " + destFile;
}
throw new BuildException(msg, ioe, getLocation());
}
}
}
|
public void | setDestDir(java.io.File destDir)The dest dir attribute.
this.destDir = destDir;
|
public void | setGranularity(long granularity)Set the number of milliseconds leeway to give before deciding a
target is out of date.
TODO: This is not yet used.
this.granularity = granularity;
|
public void | setPath(org.apache.tools.ant.types.Path s)Set the path to be used when running the Java class.
createPath().append(s);
|
public void | setPathRef(org.apache.tools.ant.types.Reference r)Set the path to use by reference.
createPath().setRefid(r);
|
public void | setPreserveLastModified(boolean preserveLastModified)Give the copied files the same last modified time as the original files.
this.preserveLastModified = preserveLastModified;
|
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.
if (destDir == null) {
throw new BuildException(ERROR_NO_DESTDIR);
}
if (mapper == null) {
throw new BuildException(ERROR_NO_MAPPER);
}
if (path == null) {
throw new BuildException(ERROR_NO_PATH);
}
|