In Gradle 1.7 it's fine.
In Gradle 1.8 also the directory for a matching file is returned and even the base directory for non matching files are returned.
build.gradle:
task filterTest(type: Copy) {
['mkdir -p dir1/dir2/',
'touch dir1/dir2/file',
'zip -r dir1.zip dir1/',
'tar -cf dir1.tar dir1/'].each
{ it.execute() }
into(buildDir)
from(fileTree(dir: 'dir1').matching
{ include 'dir2/file' }
) { eachFile
{ println "### dir - matching ### $it" }
}
from(zipTree('dir1.zip').matching
{ include 'dir1/dir2/file' }) { eachFile { println "### zip - matching ### $it" } }
from(tarTree('dir1.tar').matching{ include 'dir1/dir2/file' }
) { eachFile
{ println "### tar - matching ### $it" }
}
from(fileTree(dir: 'dirx').matching
{ include 'xxxx/file' }
) { eachFile
{ println "### dir - not matching ### $it" }
}
from(zipTree('dir1.zip').matching
{ include 'dir1/xxxx/file' }) { eachFile { println "### zip - not matching ### $it" } }
from(tarTree('dir1.tar').matching{ include 'dir1/xxxx/file' }
) { eachFile
{ println "### tar - not matching ### $it" }
}
}
Gradle 1.7 output:
$ gvm use gradle 1.7
$ rm -rf build
$ gradle filterTest
:filterTest
-
-
- dir - matching ### file 'project/dir1/dir2/file'
- zip - matching ### zip entry project/dir1.zip!dir1/dir2/file
- tar - matching ### tar entry project/dir1.tar!dir1/dir2/file
Gradle 1.8 output:
$ gvm use gradle 1.8
$ rm -rf build
$ gradle filterTest
:filterTest
-
-
- dir - matching ### file 'project/dir1/dir2'
- dir - matching ### file 'project/dir1/dir2/file'
- zip - matching ### zip entry project/dir1.zip!dir1/
- zip - matching ### zip entry project/dir1.zip!dir1/dir2/
- zip - matching ### zip entry project/dir1.zip!dir1/dir2/file
- tar - matching ### tar entry project/dir1.tar!dir1/
- tar - matching ### tar entry project/dir1.tar!dir1/dir2/
- tar - matching ### tar entry project/dir1.tar!dir1/dir2/file
- zip - not matching ### zip entry project/dir1.zip!dir1/
- tar - not matching ### tar entry project/dir1.tar!dir1/
|