I'm writing an custom ant task in java. I would like to get a list of all the files within a FileSet. What is the best way to do this?
+1
A:
Have a look at the example from Tutorial: Tasks using Properties, Filesets & Paths:
FileSet fs;
// ...
DirectoryScanner ds = fs.getDirectoryScanner(getProject());
String[] includedFiles = ds.getIncludedFiles();
for(int i=0; i<includedFiles.length; i++) {
String filename = includedFiles[i].replace('\\','/');
...
}
Peter Lang
2010-05-06 10:29:39
You might prefer to use Union.listResources(). It returns a Resource[], which might be easier to deal with.Unfortunately, good documentation appears to be lacking. Have a look at the source: http://svn.apache.org/repos/asf/ant/core/tags/ANT_171/src/main/org/apache/tools/ant/types/resources/Union.javaI used this in jslint4java: http://github.com/happygiraffe/jslint4java/blob/master/jslint4java-ant/src/main/java/com/googlecode/jslint4java/ant/JSLintTask.java
Dominic Mitchell
2010-05-06 11:32:58