Adam
02/22/2025, 10:57 AMb/
directory. So why does filteredFiles.asPath
contain b/test2.txt
?
val someFiles = objects.fileCollection()
.from(
"a/test1.txt",
"a/test1.dat",
"b/test2.txt",
"b/test2.dat",
)
someFiles.forEach {
it.parentFile.mkdirs()
it.writeText(it.name)
}
val filteredFiles = someFiles.asFileTree.matching {
include("**.txt")
exclude("**/b/**")
}
println("filteredFiles: ${filteredFiles.asPath}")
Vampire
02/22/2025, 6:26 PMb/test2.txt
to the file collection, that is the base path and so your pattern is only applied to test2.txt
which makes the include work, but the exclude not.
Even if you would have .from("a", "b")
it would not be different as still a
and b
are the root paths and the patterns start after that.
If you would have .from(".")
, then the patterns would work, but also b/**
or even b/
would be enough as the matched path starts with b
, unless you really also want to match deeper `b`s.
If you want to match on the full path, I think using exclude { ... }
should work.