api / org.gradle.api / Project / fileTree

fileTree

abstract fun fileTree(baseDir: Any): ConfigurableFileTree

Creates a new ConfigurableFileTree using the given base directory. The given baseDir path is evaluated as per #file(Object).

The returned file tree is lazy, so that it scans for files only when the contents of the file tree are queried. The file tree is also live, so that it scans for files each time the contents of the file tree are queried.

 def myTree = fileTree("src") myTree.include "**/*.java" myTree.builtBy "someTask" task copy(type: Copy) { from myTree } 

Parameters

baseDir - The base directory of the file tree. Evaluated as per #file(Object).

Return
the file tree. Never returns null.

abstract fun fileTree(baseDir: Any, configureClosure: Closure<Any>): ConfigurableFileTree

Creates a new ConfigurableFileTree using the given base directory. The given baseDir path is evaluated as per #file(Object). The closure will be used to configure the new file tree. The file tree is passed to the closure as its delegate. Example:

 def myTree = fileTree('src') { exclude '**/.data/**' builtBy 'someTask' } task copy(type: Copy) { from myTree } 

The returned file tree is lazy, so that it scans for files only when the contents of the file tree are queried. The file tree is also live, so that it scans for files each time the contents of the file tree are queried.

Parameters

baseDir - The base directory of the file tree. Evaluated as per #file(Object).

configureClosure - Closure to configure the ConfigurableFileTree object.

Return
the configured file tree. Never returns null.

abstract fun fileTree(baseDir: Any, configureAction: Action<in ConfigurableFileTree>): ConfigurableFileTree

Creates a new ConfigurableFileTree using the given base directory. The given baseDir path is evaluated as per #file(Object). The action will be used to configure the new file tree. Example:

 def myTree = fileTree('src') { exclude '**/.data/**' builtBy 'someTask' } task copy(type: Copy) { from myTree } 

The returned file tree is lazy, so that it scans for files only when the contents of the file tree are queried. The file tree is also live, so that it scans for files each time the contents of the file tree are queried.

Parameters

baseDir - The base directory of the file tree. Evaluated as per #file(Object).

configureAction - Action to configure the ConfigurableFileTree object.

Return
the configured file tree. Never returns null.

Since
3.5

abstract fun fileTree(args: MutableMap<String, *>): ConfigurableFileTree

Creates a new ConfigurableFileTree using the provided map of arguments. The map will be applied as properties on the new file tree. Example:

 def myTree = fileTree(dir:'src', excludes:['**/ignore/**', '**/.data/**']) task copy(type: Copy) { from myTree } 

The returned file tree is lazy, so that it scans for files only when the contents of the file tree are queried. The file tree is also live, so that it scans for files each time the contents of the file tree are queried.

Parameters

args - map of property assignments to ConfigurableFileTree object

Return
the configured file tree. Never returns null.