# Cross project source dependency in rule based model

**URL:** <https://discuss.gradle.org/t/cross-project-source-dependency-in-rule-based-model/13526>\
**Category:** Help/Discuss\
**Created:** [January 4, 2016, 7:52pm UTC](https://discuss.gradle.org/t/cross-project-source-dependency-in-rule-based-model/13526 "2016-01-04T19:52:14Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![ethankhall](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/ethankhall/32/2564_2.png) [@ethankhall](https://discuss.gradle.org/u/ethankhall)\
**Post date:** [January 4, 2016, 7:52pm UTC](https://discuss.gradle.org/t/cross-project-source-dependency-in-rule-based-model/13526/1 "2016-01-04T19:52:14Z")

</div>

I am looking at using the new Software Model and would like to define source files in one project, but in a different project need to read the source files as well. Is it possible to access another project’s model and read where the source sets are?

---

<div class="post-metadata">

**Author:** ![mark\_vieira](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/mark_vieira/32/5396_2.png) [@mark\_vieira](https://discuss.gradle.org/u/mark_vieira)\
**Post date:** [January 5, 2016, 4:52am UTC](https://discuss.gradle.org/t/cross-project-source-dependency-in-rule-based-model/13526/2 "2016-01-05T04:52:51Z")

</div>

There currently no way to access another project’s model. Right now interaction between projects is limited to component dependencies. In reality, _all_ interactions between projects _should_ be via dependencies on some publishable binary/artifact.

Can you elaborate on your use case? Are you simply trying to avoid duplicate configuration across projects?

---

<div class="post-metadata">

**Author:** ![ethankhall](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/ethankhall/32/2564_2.png) [@ethankhall](https://discuss.gradle.org/u/ethankhall)\
**Post date:** [January 5, 2016, 3:18pm UTC](https://discuss.gradle.org/t/cross-project-source-dependency-in-rule-based-model/13526/3 "2016-01-05T15:18:49Z")

</div>

It would be great if I could do it with dependencies but alas, I don’t believe it is possible.

I’m writing a plugin that needs to interact with the component model (Play plugin) and does code generation. There are two places that the description files should live (by design). For the code gen to work right, the generator (java process) needs to be able to read both of the source tree’s. The best practice right now is to keep them in different gradle projects and was never a problem before because we could reach out and over to access that project.

---

<div class="post-metadata">

**Author:** ![mark\_vieira](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/mark_vieira/32/5396_2.png) [@mark\_vieira](https://discuss.gradle.org/u/mark_vieira)\
**Post date:** [January 5, 2016, 8:06pm UTC](https://discuss.gradle.org/t/cross-project-source-dependency-in-rule-based-model/13526/4 "2016-01-05T20:06:54Z")

</div>

Could this be modeled simply as a separate component of the same project? One of the things about the new software model is the line between “projects” becomes a bit more obscure. What would be a multi-project build in the legacy model can now be modeled in a single project with multiple components.

---

<div class="post-metadata">

**Author:** ![ethankhall](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/ethankhall/32/2564_2.png) [@ethankhall](https://discuss.gradle.org/u/ethankhall)\
**Post date:** [January 5, 2016, 8:23pm UTC](https://discuss.gradle.org/t/cross-project-source-dependency-in-rule-based-model/13526/5 "2016-01-05T20:23:14Z")

</div>

Thats an interesting thought… That could work. Would it be possible to make this work with both the legacy plugins (whats the right name for it?) and the rule based plugins?

When you declare multiple components how does publishing work with non model projects? One jar needs to be published so that others can consume it.

Do you know when more ‘advanced’ documentation will be available for the model? I have fallen into just reading source code and the javadoc for some of it seem to not work as expected.

---

<div class="post-metadata">

**Author:** ![mark\_vieira](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/mark_vieira/32/5396_2.png) [@mark\_vieira](https://discuss.gradle.org/u/mark_vieira)\
**Post date:** [January 5, 2016, 8:47pm UTC](https://discuss.gradle.org/t/cross-project-source-dependency-in-rule-based-model/13526/6 "2016-01-05T20:47:04Z")

</div>

> [@ethankhall](#):
>
> When you declare multiple components how does publishing work with non model projects? One jar needs to be published so that others can consume it.

That would continue to be a problem. Right now legacy project dependencies won’t work for projects that declare multiple publications.

> [@ethankhall](#):
>
> Do you know when more ‘advanced’ documentation will be available for the model? I have fallen into just reading source code and the javadoc for some of it seem to not work as expected.

Soon 🙂

---

<div class="post-metadata">

**Author:** ![ethankhall](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/ethankhall/32/2564_2.png) [@ethankhall](https://discuss.gradle.org/u/ethankhall)\
**Post date:** [January 5, 2016, 9:10pm UTC](https://discuss.gradle.org/t/cross-project-source-dependency-in-rule-based-model/13526/7 "2016-01-05T21:10:33Z")

</div>

Hum… Would I be able to publish to multiple configurations and have the legacy projects depend on a configuration?

I hope it’s not a Blizzard style soon. 🙂

---

<div class="post-metadata">

**Author:** ![mark\_vieira](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/mark_vieira/32/5396_2.png) [@mark\_vieira](https://discuss.gradle.org/u/mark_vieira)\
**Post date:** [January 5, 2016, 10:24pm UTC](https://discuss.gradle.org/t/cross-project-source-dependency-in-rule-based-model/13526/8 "2016-01-05T22:24:13Z")

</div>

> [@ethankhall](#):
>
> Hum… Would I be able to publish to multiple configurations and have the legacy projects depend on a configuration?

That is a potential workaround. If you are publishing Ivy modules as well that will work for consuming via an external dependency as well. This typically won’t work for folks publishing POMs since all artifacts will share the same dependencies.

---

<div class="post-metadata">

**Author:** ![ethankhall](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/ethankhall/32/2564_2.png) [@ethankhall](https://discuss.gradle.org/u/ethankhall)\
**Post date:** [January 5, 2016, 10:38pm UTC](https://discuss.gradle.org/t/cross-project-source-dependency-in-rule-based-model/13526/9 "2016-01-05T22:38:44Z")

</div>

As it turns out, I am publishing using Ivy 🙂

Is there anything special for publishing multiple artifacts from different components with the model?

---

<div class="post-metadata">

**Author:** ![mark\_vieira](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/mark_vieira/32/5396_2.png) [@mark\_vieira](https://discuss.gradle.org/u/mark_vieira)\
**Post date:** [January 5, 2016, 10:42pm UTC](https://discuss.gradle.org/t/cross-project-source-dependency-in-rule-based-model/13526/10 "2016-01-05T22:42:00Z")

</div>

If you are already publishing binaries then I don’t imagine there would be anything special about it other than ensuring the artifact names are different (unique classifiers, etc).

---

<div class="post-metadata">

**Author:** ![ethankhall](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/ethankhall/32/2564_2.png) [@ethankhall](https://discuss.gradle.org/u/ethankhall)\
**Post date:** [January 5, 2016, 10:46pm UTC](https://discuss.gradle.org/t/cross-project-source-dependency-in-rule-based-model/13526/11 "2016-01-05T22:46:09Z")

</div>

Awesome thanks Mark!
