I want to use fileScanner of AntBuilder to go over directories.
My code looks like:
scanner = new AntBuilder().fileScanner {
fileset(dir:sourcedir, casesensitive:false) {
include(name:pattern)
type(type:'dir')
}
}
I want to loop with the scanner just on directories, for example:
for (file in scanner) {
assert file.directory == true
}
Any idea ?
Thanks!!!!!!!!
Here's how to do it with fileScanner
scanner = new AntBuilder().fileScanner {
fileset(dir:sourcedir, casesensitive:false) {
include(name:pattern)
}
}
// Just the directories
scanner.directories().each {
println it.name
}
You could also do it with Groovy calls:
def dirs = []
new File( sourcedir ).eachDirRecurse {
// Check the name here, obviously the Ant pattern you have probably won't work
if( it.name ==~ pattern ) dirs << it
}
dirs.each {
println it.name
}