Depending on another projects sourceset output

down vote
I have a user defined sourcesets (mysourceset) in project A, and in project B want to depend on its output. I tried

testCompile project(path: ‘:A’, configuration: ‘mysourcesetCompile’) but no luck.

Also tried creating a configuration in project A and using it in project B as follows. testCompile project(’:A’).configurations.myconfig

also no luck!

I tried project(’:A’).files(’.’) which worked at the end. But looking for a better solution. Uploaded a mini sample project to:

1 Like

The problem was solved by project(’:a’).sourceSets.mysourceset.output. Just had to make sure that I use evaluationDependsOn(’:a’) in b.gradle.

1 Like

Your first attempt at using configurations is a much better solution than using evaluationDependsOn and depending on internals of other projects. You just missed a couple things.

Project A needs to define the configuration, but it also needs to add an appropriate artifact to it.

configurations {
    mineConf.extendsFrom mineCompile

task mineJar(type: Jar) {
    classifier = 'mine'
    from sourceSets.mine.output

artifacts {
    mineConf mineJar

Project B could then depend on it, using the same configuration name was used to expose the artifact.

testCompile project(path: ':A', configuration: 'mineConf')

Thanks a lot for the nice and detailed solution.