Get a list of all the files in a directory (recursive)

前端 未结 4 953
灰色年华
灰色年华 2020-12-23 02:59

I\'m trying to get (not print, that\'s easy) the list of files in a directory and its sub directories.

I\'ve tried:

def folder = \"C:\\\\DevEnv\\\\Pr         


        
4条回答
  •  没有蜡笔的小新
    2020-12-23 03:23

    The following works for me in Gradle / Groovy for build.gradle for an Android project, without having to import groovy.io.FileType (NOTE: Does not recurse subdirectories, but when I found this solution I no longer cared about recursion, so you may not either):

    FileCollection proGuardFileCollection = files { file('./proguard').listFiles() }
    proGuardFileCollection.each {
        println "Proguard file located and processed: " + it
    }
    

提交回复
热议问题