Hi
The code below should do it. Use two from blocks, one with an exclude and the
other one with an include of the inverse of a given pattern.
task copyFiles(type: Copy) {
into buildDir
from(webAppDir) {
exclude '**/*.bak'
filter { line -> line.trim() }
}
from(webAppDir) {
include '**/*.bak'
}
}
Regards, Etienne
On 09.01.2011, at 09:36, Nicolas Labrot wrote:
> Hello,
>
> I want to copy a directory and apply a content filtering only to some files,
> ie. a conditional filtering (eg. all xml files will be filtered and the other
> files will be copied as it). Thanks to the documentation, copy and filtering
> with include and exclude is quite clear. But it apply to all files.
>
> The common (maven and ant) workaround uses two copy tasks. One with include
> "*.xml" and the filtering on, one with the exclude "*.xml" and the filtering
> off. It's a bit cumbersome.
>
> Does Gradle handles conditional filtering ? [1]
>
> Thanks for your help^.
>
>
> [1] For example :
> task(type: Copy) {
> from 'src/main/resources'
> into buildDir
> filter( '**/*.txt' , ...)
> }
>