diff --git a/WHATSNEW b/WHATSNEW index b3d84d9f3..4d9abc442 100644 --- a/WHATSNEW +++ b/WHATSNEW @@ -586,6 +586,10 @@ Other changes: as nested element of and friends. Bugzilla Report 46257. + * has a new verbose attribute that makes the task list + all deleted targets and give a hint as to why it deleted them. + Bugzilla Report 13681. + Changes from Ant 1.7.0 TO Ant 1.7.1 ============================================= diff --git a/docs/manual/CoreTasks/dependset.html b/docs/manual/CoreTasks/dependset.html index cb902d622..982c80306 100644 --- a/docs/manual/CoreTasks/dependset.html +++ b/docs/manual/CoreTasks/dependset.html @@ -59,9 +59,19 @@ well as other stylesheets imported by the main stylesheet.

Parameters

-

-(none) -

+ + + + + + + + + + + +
AttributeDescriptionRequired
verboseMakes the task list all deleted targets files + and the reason why they get deleted.No

Parameters Specified as Nested Elements

diff --git a/src/main/org/apache/tools/ant/taskdefs/DependSet.java b/src/main/org/apache/tools/ant/taskdefs/DependSet.java index 8fcd14fea..8633c2d23 100644 --- a/src/main/org/apache/tools/ant/taskdefs/DependSet.java +++ b/src/main/org/apache/tools/ant/taskdefs/DependSet.java @@ -19,6 +19,7 @@ package org.apache.tools.ant.taskdefs; import java.io.File; +import java.util.Date; import java.util.Iterator; import org.apache.tools.ant.BuildException; import org.apache.tools.ant.Project; @@ -119,6 +120,8 @@ public class DependSet extends MatchingTask { private Union sources = null; private Path targets = null; + private boolean verbose; + /** * Create a nested sources element. * @return a Union instance. @@ -169,6 +172,19 @@ public class DependSet extends MatchingTask { createTargets().add(fl); } + /** + * In verbose mode missing targets and sources as well as the + * modification times of the newest source and latest target will + * be logged as info. + * + *

All deleted files will be logged as well.

+ * + * @since Ant 1.8.0 + */ + public void setVerbose(boolean b) { + verbose = b; + } + /** * Execute the task. * @throws BuildException if errors occur. @@ -185,6 +201,12 @@ public class DependSet extends MatchingTask { //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); + if (verbose) { + String[] t = targets.list(); + for (int i = 0; i < t.length; i++) { + log("Deleting " + t[i]); + } + } Delete delete = new Delete(); delete.bindToOwner(this); delete.add(targets); @@ -202,23 +224,27 @@ public class DependSet extends MatchingTask { datesel.setGranularity(0); logFuture(targets, datesel); - int neTargets = new NonExistent(targets).size(); + NonExistent missingTargets = new NonExistent(targets); + int neTargets = missingTargets.size(); if (neTargets > 0) { log(neTargets + " nonexistent targets", Project.MSG_VERBOSE); + logMissing(missingTargets, "target"); return false; } Resource oldestTarget = getOldest(targets); - log(oldestTarget + " is oldest target file", Project.MSG_VERBOSE); + logWithModificationTime(oldestTarget, "oldest target file"); logFuture(sources, datesel); - int neSources = new NonExistent(sources).size(); + NonExistent missingSources = new NonExistent(sources); + int neSources = missingSources.size(); if (neSources > 0) { log(neSources + " nonexistent sources", Project.MSG_VERBOSE); + logMissing(missingSources, "source"); return false; } Resource newestSource = (Resource) getNewest(sources); - log(newestSource.toLongString() + " is newest source", Project.MSG_VERBOSE); + logWithModificationTime(newestSource, "newest source"); return oldestTarget.getLastModified() >= newestSource.getLastModified(); } @@ -255,4 +281,18 @@ public class DependSet extends MatchingTask { return getXest(rc, DATE); } + private void logWithModificationTime(Resource r, String what) { + log(r.toLongString() + " is " + what + ", modified at " + + new Date(r.getLastModified()), + verbose ? Project.MSG_INFO : Project.MSG_VERBOSE); + } + + private void logMissing(ResourceCollection missing, String what) { + if (verbose) { + for (Iterator i = missing.iterator(); i.hasNext(); ) { + Resource r = (Resource) i.next(); + log("Expected " + what + " " + r.toLongString() + " is missing."); + } + } + } } diff --git a/src/tests/antunit/taskdefs/dependset-test.xml b/src/tests/antunit/taskdefs/dependset-test.xml index 387f96cbb..721dc29e8 100644 --- a/src/tests/antunit/taskdefs/dependset-test.xml +++ b/src/tests/antunit/taskdefs/dependset-test.xml @@ -54,6 +54,8 @@
+ @@ -64,6 +66,12 @@ + + + @@ -82,6 +90,12 @@ + + + @@ -96,6 +110,10 @@ + + @@ -110,6 +128,8 @@ + @@ -122,6 +142,8 @@ +