Exclude not working on Copy task

I am trying to copy all my dependencies to a single directory while excluding a set of dependencies which are special. These special dependencies are actually plugins which I want in a separate directory. I’ve defined the special dependencies in the plugins property and then include or exclude when copying the dependencies.

project.ext {
    plugins = [
                'plugin-A-*.jar',
                'plugin-B-*.jar',
                'plugin-C-*.jar'
                ]
}
    task copyLibs(type: Copy) {
 into "$buildDir/lib"
 from configurations.installer {
  exclude project.plugins
 }
}
  task copyPlugins(type: Copy) {
 into "$buildDir/bin"
 from configurations.installer {
  include project.plugins
 }
}

The problem is that when executed all dependencies are copied to “$buildDir/lib” and nothing is copied to “$buildDir/bin”. So, it would appear that the include and/or the exclude is not working. Is there any reason why this would not work? How can I achieve what I want?

Erich,

I think what is going on is that “project.plugins” in your include/exclude statements refer to the Gradle project, plugin property, not your ext property.

See also: The “plugins” property here: http://gradle.org/docs/current/dsl/org.gradle.api.Project.html

Note: Assuming the folders and representative files are in the stuff folder, the simplified tasks, below, work as expected.

Hope this helps. Tom

apply plugin: 'base'
  ext.pluginFilter = ['plugin-A-*.jar', 'plugin-B-*.jar']
  task makeLib(type:Copy) {
 into ('lib')
 from ('stuff') {
  exclude pluginFilter
 }
}
task makeBin(type:Copy) {
 into ('bin')
 from ('stuff') {
  include pluginFilter
 }
}

Erich,

Did Tom’s suggestion solve your problem?

Yes, the issue was that I was using the same name as the already existing ‘plugins’ property. The solution was to change my property’s name to ‘pluginFilter’.

Thanks.