Gradle jar plugin

Hi,
I have a java module that I am trying to build using gradle, It has some generated sources in a different folder that are needed only for compile. I have this in build.gradle

sourceSets {
    main {
       java {
            srcDir '../../build-out/java'
        }
    }
}

But my jar now has all the compiled classes from build-out/java
How do i exclude them from the packaged jar.

Thanks

You could always try building those java classes into a jar itself, and then adding that as a dependency.

But if you really don’t want to do that, the Jar task supports exclude patterns:

jar {
    excludes "**/build-out/java/*"
}

I believe that will work.