# How do you configure advanced java source sets?

**URL:** <https://discuss.gradle.org/t/how-do-you-configure-advanced-java-source-sets/3559>\
**Category:** Old Forum Archive\
**Created:** [May 21, 2013, 4:38am UTC](https://discuss.gradle.org/t/how-do-you-configure-advanced-java-source-sets/3559 "2013-05-21T04:38:00Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![cmcginty](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/cmcginty/32/2209_2.png) [@cmcginty](https://discuss.gradle.org/u/cmcginty)\
**Post date:** [May 21, 2013, 4:38am UTC](https://discuss.gradle.org/t/how-do-you-configure-advanced-java-source-sets/3559/1 "2013-05-21T04:38:00Z")

</div>

The java plugin documentation is very detailed but does show any advanced examples:

1. Please explain how to create a source set that filters out specific set of files inside of a source dir?

What is wrong with this code?

```gradle
sourceSets {
    main {
        java {
            source fileTree( dir: 'src')
        }
    }

```

1. Please explain how to use a custom source set name other than main or test. How do you tell gradle to compile/jar the custom source set?

---

<div class="post-metadata">

**Author:** ![Peter\_Niederwieser](https://avatars.discourse-cdn.com/v4/letter/p/9f8e36/32.png) [@Peter\_Niederwieser](https://discuss.gradle.org/u/Peter_Niederwieser)\
**Post date:** [May 21, 2013, 8:13am UTC](https://discuss.gradle.org/t/how-do-you-configure-advanced-java-source-sets/3559/2 "2013-05-21T08:13:00Z")

</div>

ad 1. Sources are always directories, not individual files. You can declare ‘include’ and ‘exclude’ filters on the ‘SourceDirectorySet’ level (e.g. ‘sourceSets.main.java.exclude “\*\*/\*Test.java”’). You cannot currently have different filters per directory.

ad 2. With the ‘java(-base)’ plugin, you automatically get a compile task for each source set. The Jar task you’ll have to declare yourself. See the ‘withIntegTests’ sample in the full Gradle distribution for how to configure a custom source set.
