[GRADLE-2900] FileTree.matching() may return unmatched files Created: 27/Sep/13  Updated: 06/Oct/13  Resolved: 06/Oct/13

Status: Resolved
Project: Gradle
Affects Version/s: None
Fix Version/s: 1.9-rc-1

Type: Bug
Reporter: Gradle Forums Assignee: Benjamin Muschko
Resolution: Fixed Votes: 0

Known Issue Of:
1.8

 Description   

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

      1. dir - matching ### file 'project/dir1/dir2/file'
      2. zip - matching ### zip entry project/dir1.zip!dir1/dir2/file
      3. 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

      1. dir - matching ### file 'project/dir1/dir2'
      2. dir - matching ### file 'project/dir1/dir2/file'
      3. zip - matching ### zip entry project/dir1.zip!dir1/
      4. zip - matching ### zip entry project/dir1.zip!dir1/dir2/
      5. zip - matching ### zip entry project/dir1.zip!dir1/dir2/file
      6. tar - matching ### tar entry project/dir1.tar!dir1/
      7. tar - matching ### tar entry project/dir1.tar!dir1/dir2/
      8. tar - matching ### tar entry project/dir1.tar!dir1/dir2/file
      9. zip - not matching ### zip entry project/dir1.zip!dir1/
      10. tar - not matching ### tar entry project/dir1.tar!dir1/

Generated at Wed Jun 30 12:34:29 CDT 2021 using Jira 8.4.2#804003-sha1:d21414fc212e3af190e92c2d2ac41299b89402cf.