Custom SourceSets and the build classpath

Hello. I have a simple question regarding source sets. I defined two new source sets: ‘api’ and ‘impl’. I understand that gradle create a set of tasts and configurations for each one of them, however, they are not automatically included in the build or runtime classpath nor exported to the default generated jar. In the end I had to do this:

sourceSets {

api

impl }

dependencies {

testCompile sourceSets.api.output

testCompile sourceSets.impl.output

runtime configurations.apiRuntime

runtime configurations.implRuntime }

Is that really the intended way? Is there a simpler solution? I’d just like to avoid configuring every classpath and export for every single source set I add.

Ok. I just used the snippet of code below, which is exactly my intent. No need to create new source sets. I was trying ‘srcDir’ instead of ‘srcDirs’.

sourceSets {

main {

java {

srcDirs = [‘src/api/java’,‘src/impl/java’]

}

} }