# Depending on another projects sourceset output

**URL:** <https://discuss.gradle.org/t/depending-on-another-projects-sourceset-output/24584>\
**Category:** Help/Discuss\
**Created:** [October 30, 2017, 3:28pm UTC](https://discuss.gradle.org/t/depending-on-another-projects-sourceset-output/24584 "2017-10-30T15:28:53Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![amirhossein.gh](https://avatars.discourse-cdn.com/v4/letter/a/b487fb/32.png) [@amirhossein.gh](https://discuss.gradle.org/u/amirhossein.gh)\
**Post date:** [October 30, 2017, 3:28pm UTC](https://discuss.gradle.org/t/depending-on-another-projects-sourceset-output/24584/1 "2017-10-30T15:28:53Z")

</div>

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](https://github.com/ghamarian/gradleproblem)

---

<div class="post-metadata">

**Author:** ![amirhossein.gh](https://avatars.discourse-cdn.com/v4/letter/a/b487fb/32.png) [@amirhossein.gh](https://discuss.gradle.org/u/amirhossein.gh)\
**Post date:** [October 31, 2017, 1:49pm UTC](https://discuss.gradle.org/t/depending-on-another-projects-sourceset-output/24584/2 "2017-10-31T13:49:24Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![jjustinic](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/jjustinic/32/9005_2.png) [@jjustinic](https://discuss.gradle.org/u/jjustinic)\
**Post date:** [October 31, 2017, 4:09pm UTC](https://discuss.gradle.org/t/depending-on-another-projects-sourceset-output/24584/3 "2017-10-31T16:09:44Z")

</div>

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.

```groovy
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.

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

```

---

<div class="post-metadata">

**Author:** ![amirhossein.gh](https://avatars.discourse-cdn.com/v4/letter/a/b487fb/32.png) [@amirhossein.gh](https://discuss.gradle.org/u/amirhossein.gh)\
**Post date:** [October 31, 2017, 8:18pm UTC](https://discuss.gradle.org/t/depending-on-another-projects-sourceset-output/24584/4 "2017-10-31T20:18:22Z")

</div>

Thanks a lot for the nice and detailed solution.
