This is what I came up with for a gradle build script:
task doLast {
ext.FindFile = { list, curPath ->
def files = file(curPath).listFiles().sort()
files.each { File file ->
if (file.isFile()) {
list << file
}
else {
list << file // If you want the directories in the list
list = FindFile( list, file.path)
}
}
return list
}
def list = []
def theFile = FindFile(list, "${project.projectDir}")
list.each {
println it.path
}
}