Methods Summary |
---|
public void | addSrcfilelist(org.apache.tools.ant.types.FileList fl)Add a list of source files.
createSources().add(fl);
|
public void | addSrcfileset(org.apache.tools.ant.types.FileSet fs)Add a set of source files.
createSources().add(fs);
|
public void | addTargetfilelist(org.apache.tools.ant.types.FileList fl)Add a list of target files.
createTargets().add(fl);
|
public void | addTargetfileset(org.apache.tools.ant.types.FileSet fs)Add a set of target files.
createTargets().add(new HideMissingBasedir(fs));
|
public synchronized org.apache.tools.ant.types.resources.Union | createSources()Create a nested sources element.
sources = (sources == null) ? new Union() : sources;
return sources;
|
public synchronized org.apache.tools.ant.types.Path | createTargets()Create a nested targets element.
targets = (targets == null) ? new Path(getProject()) : targets;
return targets;
|
public void | execute()Execute the task.
if (sources == null) {
throw new BuildException(
"At least one set of source resources must be specified");
}
if (targets == null) {
throw new BuildException(
"At least one set of target files must be specified");
}
//no sources = nothing to compare; no targets = nothing to delete:
if (sources.size() > 0 && targets.size() > 0 && !uptodate(sources, targets)) {
log("Deleting all target files.", Project.MSG_VERBOSE);
Delete delete = new Delete();
delete.bindToOwner(this);
delete.add(targets);
delete.perform();
}
|
private void | logFuture(org.apache.tools.ant.types.ResourceCollection rc, org.apache.tools.ant.types.resources.selectors.ResourceSelector rsel)
Restrict r = new Restrict();
r.add(rsel);
r.add(rc);
for (Iterator i = r.iterator(); i.hasNext();) {
log("Warning: " + i.next() + " modified in the future.", Project.MSG_WARN);
}
|
private boolean | uptodate(org.apache.tools.ant.types.ResourceCollection src, org.apache.tools.ant.types.ResourceCollection target)
org.apache.tools.ant.types.resources.selectors.Date datesel
= new org.apache.tools.ant.types.resources.selectors.Date();
datesel.setMillis(System.currentTimeMillis());
datesel.setWhen(TimeComparison.AFTER);
logFuture(targets, datesel);
int neTargets = new NonExistent(targets).size();
if (neTargets > 0) {
log(neTargets + " nonexistent targets", Project.MSG_VERBOSE);
return false;
}
FileResource oldestTarget = (FileResource) (new Oldest(targets).iterator().next());
log(oldestTarget + " is oldest target file", Project.MSG_VERBOSE);
logFuture(sources, datesel);
int neSources = new NonExistent(sources).size();
if (neSources > 0) {
log(neSources + " nonexistent sources", Project.MSG_VERBOSE);
return false;
}
Resource newestSource = (Resource) (new Newest(sources).iterator().next());
log(newestSource.toLongString() + " is newest source", Project.MSG_VERBOSE);
return oldestTarget.getLastModified() >= newestSource.getLastModified();
|