fileTree

abstract fun fileTree(baseDir: Any): ConfigurableFileTree(source)

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

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
}

The order of the files in a FileTree is not stable, even on a single computer.

Return

the file tree. Never returns null.

Parameters

baseDir

The base directory of the file tree. Evaluated as per file.


abstract fun fileTree(baseDir: Any, @DelegatesTo(value = ConfigurableFileTree::class) configureClosure: Closure): ConfigurableFileTree(source)

Creates a new ConfigurableFileTree using the given base directory. The given baseDir path is evaluated as per file. 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.

The order of the files in a FileTree is not stable, even on a single computer.

Return

the configured file tree. Never returns null.

Parameters

baseDir

The base directory of the file tree. Evaluated as per file.

configureClosure

Closure to configure the ConfigurableFileTree object.


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

Creates a new ConfigurableFileTree using the given base directory. The given baseDir path is evaluated as per file. 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.

The order of the files in a FileTree is not stable, even on a single computer.

Return

the configured file tree. Never returns null.

Since

3.5

Parameters

baseDir

The base directory of the file tree. Evaluated as per file.

configureAction

Action to configure the ConfigurableFileTree object.


abstract fun fileTree(args: Map<String, out Any>): ConfigurableFileTree(source)

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.

The order of the files in a FileTree is not stable, even on a single computer.

Return

the configured file tree. Never returns null.

Parameters

args

map of property assignments to ConfigurableFileTree object