Using Gradle 2.1 I observed the following inconsistency between the include and exclude options on FileCollections.
Given the following file structure
files/ignoreMe.txt
files/com/company/foo.class
files/org/group/bar.class
I tried creating a FileTree including all files, except those within the root of the source folder.
fileTree('files') {
exclude ('*')
}
which I would expect to contain all files but ignoreMe.txt. Instead it contains no files at all, acting as if ‘**’ was defined. At the same time using the same pattern in include works as expected:
fileTree('files') {
include ('*')
}
As this FileTree contains only ignoreMe.txt.
The expected behavior can be described using this work-around:
fileTree('files') {
exclude { FileTreeElement element ->
!element.directory && element.relativePath.segments.length == 1
}
}