Depending on another projects sourceset output


(Amir Hossein Ghamarian) #1

0
down vote
favorite
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: https://github.com/ghamarian/gradleproblem


(Amir Hossein Ghamarian) #2

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


(James Justinic) #3

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')

(Amir Hossein Ghamarian) #4

Thanks a lot for the nice and detailed solution.