# Sourced SourceDirectorySet ignores 'exclude' settings

**URL:** <https://discuss.gradle.org/t/sourced-sourcedirectoryset-ignores-exclude-settings/6152>\
**Category:** Old Forum Archive\
**Created:** [June 19, 2013, 1:42pm UTC](https://discuss.gradle.org/t/sourced-sourcedirectoryset-ignores-exclude-settings/6152 "2013-06-19T13:42:00Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![wujek\_srujek](https://avatars.discourse-cdn.com/v4/letter/w/ee7513/32.png) [@wujek\_srujek](https://discuss.gradle.org/u/wujek_srujek)\
**Post date:** [June 19, 2013, 1:42pm UTC](https://discuss.gradle.org/t/sourced-sourcedirectoryset-ignores-exclude-settings/6152/1 "2013-06-19T13:42:00Z")

</div>

I’m using Gradle 1.6. For the following project:

```gradle
apply plugin: 'groovy'
sourceSets {
  main {
    resources {
      source java
      exclude '**/*.xml'
    }
     }
}

```

with the following files:

```gradle
$ find src -type f
src/main/java/java.java
src/main/java/java.xml
src/main/java/java.txt
src/main/resources/resource.txt
src/main/resources/resource.xml
src/main/resources/resource.java

```

calling './gradlew clean processResources _does not_ exclude \*.xml files form src/main/java:

```gradle
$ ./gradlew clean processResources
:clean
:processResources
BUILD SUCCESSFUL
Total time: 3.102 secs
  $ find build -type f | sort
build/resources/main/java.txt
build/resources/main/java.xml
build/resources/main/resource.java
build/resources/main/resource.txt

```

I would expect the java.xml file not to be copied over. Is this supposed to work this way?

wujek

---

<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:** [June 20, 2013, 7:58pm UTC](https://discuss.gradle.org/t/sourced-sourcedirectoryset-ignores-exclude-settings/6152/2 "2013-06-20T19:58:00Z")

</div>

It should be:

```gradle
apply plugin: 'groovy'
sourceSets {
  main {
    resources {
      srcDirs java.srcDirs
      exclude '**/*.xml'
    }
     }
}

```

Using the source method means that the other source directory set should be included wholesale (i.e. includes/excludes don’t apply).

---

<div class="post-metadata">

**Author:** ![wujek\_srujek](https://avatars.discourse-cdn.com/v4/letter/w/ee7513/32.png) [@wujek\_srujek](https://discuss.gradle.org/u/wujek_srujek)\
**Post date:** [June 20, 2013, 8:18pm UTC](https://discuss.gradle.org/t/sourced-sourcedirectoryset-ignores-exclude-settings/6152/3 "2013-06-20T20:18:00Z")

</div>

No, I had tried that before, there is even a post by me asking somewhere in this forum. What I get is:

```gradle
$ g clean processResources
Converting class java.util.LinkedHashSet to File using toString() method has been deprecated and is scheduled to be removed in Gradle 2.0. Please use java.io.File, java.lang.String, java.net.URL, or java.net.URI instead.
:clean
:processResources
  BUILD SUCCESSFUL
  Total time: 6.801 secs
$ find -type f build/resources/
build/resources/main/resource.txt
build/resources/main/resource.java

```

Which means that src/java is not included in resources. If you want it this way, you actually need to do it like this:

```gradle
srcDirs java.srcDirs as File[]

```

or

```gradle
srcDirs = srcDirs + java.srcDirs

```

I don’t like the looks of the former, and I’ve just came up with the latter ;d That’s why I went on to search deeper and found ‘source’. I guess I will have to live with one of the two. I do understand the reasoning behind ‘source’ being wholesale, it was just surprising at first, and it should probably be documented that such ‘sourcing’ is not affected by further configuration.

wujek

---

<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:** [June 20, 2013, 8:36pm UTC](https://discuss.gradle.org/t/sourced-sourcedirectoryset-ignores-exclude-settings/6152/4 "2013-06-20T20:36:00Z")

</div>

The code I posted should work, it’s a bug that it doesn’t.

I’ve raised GRADLE-2798.

---

<div class="post-metadata">

**Author:** ![wujek\_srujek](https://avatars.discourse-cdn.com/v4/letter/w/ee7513/32.png) [@wujek\_srujek](https://discuss.gradle.org/u/wujek_srujek)\
**Post date:** [June 20, 2013, 8:46pm UTC](https://discuss.gradle.org/t/sourced-sourcedirectoryset-ignores-exclude-settings/6152/5 "2013-06-20T20:46:00Z")

</div>

Ok thanks. You might also be interested in this: [http://forums.gradle.org/gradle/topics/non\_source\_files\_form\_src\_main\_java\_as\_resources\_and\_filtering](http://forums.gradle.org/gradle/topics/non_source_files_form_src_main_java_as_resources_and_filtering) (that’s the other thread I mentioned, it contains some initial analysis that I made about why the code you posted above doesn’t work).
