Hi again folks.
After some debugging and looking through the code I found that
the Available task does not do file pattern matching when using
the file attribute. So, I patched it to do that, and here's
my patch (attached). It works for me..
Again, I'd just be thrilled if this made it into the Ant
1.4.1 (final) release.
Thanks.
--
Jason Brittain
<jasonb(at)collab(dot)net>
CollabNet http://www.collab.net
--- src/main/org/apache/tools/ant/taskdefs/Available.java.orig Mon Oct 8
16:02:29 2001
+++ src/main/org/apache/tools/ant/taskdefs/Available.java Mon Oct 8
16:53:32 2001
@@ -180,14 +180,25 @@
private boolean checkFile() {
if (filepath == null) {
- return checkFile(file);
+ if (file.getName().indexOf('*') == -1) {
+ return checkFile(file);
+ } else {
+ return checkPattern(file.getName(), ".");
+ }
} else {
String[] paths = filepath.list();
for(int i = 0; i < paths.length; ++i) {
- log("Searching " + paths[i], Project.MSG_VERBOSE);
- if(new File(paths[i], file.getName()).isFile()) {
- return true;
- }
+ if (file.getName().indexOf('*') == -1) {
+ log("Searching " + paths[i], Project.MSG_VERBOSE);
+ if(checkFile(new File(paths[i], file.getName()))) {
+ return true;
+ }
+ } else {
+ log("Searching " + paths[i] +
+ " for any files matching pattern " + file.getName(),
+ Project.MSG_VERBOSE);
+ return checkPattern(file.getName(), paths[i]);
+ }
}
}
return false;
@@ -202,6 +213,21 @@
}
}
return file.exists();
+ }
+
+ private boolean checkPattern(String filePattern, String dirPath) {
+ String[] includes = { filePattern };
+ String[] excludes = {};
+ DirectoryScanner ds = new DirectoryScanner();
+ ds.setIncludes(includes);
+ ds.setExcludes(excludes);
+ ds.setBasedir(dirPath);
+ ds.scan();
+ String[] files = ds.getIncludedFiles();
+ for (int i = 0; i < files.length;i++) {
+ if (checkFile(new File(dirPath, files[i]))) return true;
+ }
+ return false;
}
private boolean checkResource(String resource) {