[GRADLE-1301] Add exclude/include pattern on filtering feature Created: 10/Jan/11  Updated: 11/Nov/13  Resolved: 11/Nov/13

Status: Resolved
Project: Gradle
Affects Version/s: 0.9.1
Fix Version/s: 1.7-rc-1

Type: Improvement
Reporter: Nicolas Labrot Assignee: Unassigned
Resolution: Fixed Votes: 2


 Description   

Gradle does not allow to copy a fileset and apply a content filtering only to a subset of the set.

The common workaround uses two copy. One with include and the filtering on, one with the exclude and the filtering off:

task copyFiles(type: Copy) {
    into buildDir
    from(webAppDir) {
        exclude '**/*.xml'
    }
    from(webAppDir) {
        include '**/*.xml'
        filter { doSomethink }
    }
}

An improvment could be to add include/exclude pattern on filtering:

 
task copyFiles(type: Copy) {
    into buildDir
    from(webAppDir) 
    filter ('**/*.xml' , doSomethink )
}


 Comments   
Comment by Adam Murdoch [ 11/Nov/13 ]

You can use filesMatching(), filesNotMatching() and eachFile() to fine tune which files are filtered. An example: http://www.gradle.org/docs/1.7/release-notes#pattern-based-file-copy-configuration

Generated at Wed Jun 30 11:52:04 CDT 2021 using Jira 8.4.2#804003-sha1:d21414fc212e3af190e92c2d2ac41299b89402cf.