This should solve your problem:
import static groovy.io.FileType.FILES
new File('.').eachFileRecurse(FILES) {
if(it.name.endsWith('.groovy')) {
println it
}
}
eachFileRecurse
takes an enum FileType that specifies that you are only interested in files. The rest of the problem is easily solved by filtering on the name of the file. Might be worth mentioning that eachFileRecurse
normally recurses over both files and folders while eachDirRecurse
only finds folders.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…