But the generated sources are packed in to the jar artifact together with the classes. Is this by design? How can I avoid it? I guess I can exclude them, but is there a neater way?
This sample snippet in the userguide is actually not demoing how to deal with generated sources. It is about dealing with generated resources. By design resources are packaged with the jar.
I found a strange problem though. Using this method and trying to exclude the main source set from eclipse, it seems that the generated dir follows with the main sourceset even though I use a different name:
sourceSets {
generatedMainSourceSet {
//let's register an output folder on the main SourceSet:
output.dir("$buildDir/generated-src/main", builtBy: 'wsdl2java')
//it is now a part of the 'main' classpath and will be a part of the jar
}
main {
java {
srcDirs = []
}
}
}
eclipse {
classpath {
sourceSets -= [sourceSets.main]
}
}
If I remove the main sourecset from eclipse, both src/main/java and build/generated-src/main are removed, if I add it, both are added. A bug?