mbenson 2004/04/23 12:33:02
Modified: src/main/org/apache/tools/ant/taskdefs ExecuteOn.java
Log:
Make <apply> differentiate between empty and up-to-date filesets/lists.
PR: 23734
Revision Changes Path
1.53 +36 -5 ant/src/main/org/apache/tools/ant/taskdefs/ExecuteOn.java
Index: ExecuteOn.java
===================================================================
RCS file:
/home/cvs/ant/src/main/org/apache/tools/ant/taskdefs/ExecuteOn.java,v
retrieving revision 1.52
retrieving revision 1.53
diff -u -r1.52 -r1.53
--- ExecuteOn.java 27 Mar 2004 21:22:58 -0000 1.52
+++ ExecuteOn.java 23 Apr 2004 19:33:02 -0000 1.53
@@ -43,6 +43,18 @@
*/
public class ExecuteOn extends ExecTask {
+ private class ExtendedDirectoryScanner extends DirectoryScanner {
+ public int getIncludedFilesCount() {
+ if (filesIncluded == null) throw new IllegalStateException();
+ return filesIncluded.size();
+ }
+
+ public int getIncludedDirsCount() {
+ if (dirsIncluded == null) throw new IllegalStateException();
+ return dirsIncluded.size();
+ }
+ }
+
protected Vector filesets = new Vector(); // contains AbstractFileSet
// (both DirSet and FileSet)
private Vector filelists = new Vector();
@@ -270,7 +282,11 @@
}
}
File base = fs.getDir(getProject());
- DirectoryScanner ds = fs.getDirectoryScanner(getProject());
+
+ ExtendedDirectoryScanner ds = new ExtendedDirectoryScanner();
+ fs.setupDirectoryScanner(ds, getProject());
+ ds.setFollowSymlinks(fs.isFollowSymlinks());
+ ds.scan();
if (!"dir".equals(currentType)) {
String[] s = getFiles(base, ds);
@@ -291,8 +307,15 @@
}
if (fileNames.size() == 0 && skipEmpty) {
- log("Skipping fileset for directory "
- + base + ". It is empty.", Project.MSG_INFO);
+ int includedCount
+ = ((!"dir".equals(currentType))
+ ? ds.getIncludedFilesCount() : 0)
+ + ((!"file".equals(currentType))
+ ? ds.getIncludedDirsCount() : 0);
+
+ log("Skipping fileset for directory " + base + ". It is "
+ + ((includedCount > 0) ? "up to date." : "empty."),
+ Project.MSG_INFO);
continue;
}
@@ -346,8 +369,16 @@
}
if (fileNames.size() == 0 && skipEmpty) {
- log("Skipping filelist for directory "
- + base + ". It is empty.", Project.MSG_INFO);
+ ExtendedDirectoryScanner ds = new
ExtendedDirectoryScanner();
+ ds.setBasedir(base);
+ ds.setIncludes(list.getFiles(getProject()));
+ ds.scan();
+ int includedCount
+ = ds.getIncludedFilesCount() +
ds.getIncludedDirsCount();
+
+ log("Skipping filelist for directory " + base + ". It is
"
+ + ((includedCount > 0) ? "up to date." : "empty."),
+ Project.MSG_INFO);
continue;
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]