# Exclude not working on Copy task

**URL:** <https://discuss.gradle.org/t/exclude-not-working-on-copy-task/5381>\
**Category:** Old Forum Archive\
**Created:** [May 7, 2012, 12:27pm UTC](https://discuss.gradle.org/t/exclude-not-working-on-copy-task/5381 "2012-05-07T12:27:00Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![erichschroeter](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/erichschroeter/32/469_2.png) [@erichschroeter](https://discuss.gradle.org/u/erichschroeter)\
**Post date:** [May 7, 2012, 12:27pm UTC](https://discuss.gradle.org/t/exclude-not-working-on-copy-task/5381/1 "2012-05-07T12:27:00Z")

</div>

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.

```gradle
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?

---

<div class="post-metadata">

**Author:** ![Tom\_Sheehan](https://avatars.discourse-cdn.com/v4/letter/t/e68b1a/32.png) [@Tom\_Sheehan](https://discuss.gradle.org/u/Tom_Sheehan)\
**Post date:** [May 8, 2012, 3:32am UTC](https://discuss.gradle.org/t/exclude-not-working-on-copy-task/5381/2 "2012-05-08T03:32:00Z")

</div>

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](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

```gradle
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
 }
}

```

---

<div class="post-metadata">

**Author:** ![luke\_daley](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/luke_daley/32/9890_2.png) [@luke\_daley](https://discuss.gradle.org/u/luke_daley)\
**Post date:** [May 15, 2012, 7:43am UTC](https://discuss.gradle.org/t/exclude-not-working-on-copy-task/5381/3 "2012-05-15T07:43:00Z")

</div>

Erich,

Did Tom’s suggestion solve your problem?

---

<div class="post-metadata">

**Author:** ![erichschroeter](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/erichschroeter/32/469_2.png) [@erichschroeter](https://discuss.gradle.org/u/erichschroeter)\
**Post date:** [May 15, 2012, 10:52am UTC](https://discuss.gradle.org/t/exclude-not-working-on-copy-task/5381/4 "2012-05-15T10:52:00Z")

</div>

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.
