Share common logic between subproject subsets
halexiev-concentric opened this issue · 2 comments
Hi Jendrik,
Thank you for sharing your idiomatic gradle project example - it seems really promising!
I have one question though regarding sharing of common logic (dependencies, plugins, etc.) between various disparate subsets of subprojects.
To give you a better perspective - we are trying to incorporate this structure and way of organising gradle builds on a company wide scale where we have a root project that includes different sets of subprojects. Some of those subproject subsets have their own common logic etc. that is not quite appropriate for build-src or living in some included build that's somehow distant from them.
For example:
root
-- subprojects/product/A
-- subprojects/product/B
-- subprojects/product/C
-- subprojects/product/C/C1
-- subprojects/product/C/C2
C1 and C2 are kind of subprojects to C and they need to share common specific to them only logic that has nothing to do with A or B.
How would you share such logic?
We had a number of discussions about this recently and I am working on more samples and documentation on the topic.
We are moving into a direction where we'll recommend to split large builds up further. That means that each component (whatever that if for you) should have its own build. And then you combine them with includeBuild(...)
. We are also fixing some inconveniences around this for 6.8 (in particular gradle/gradle#2533 and gradle/gradle#6229).
So for your example, you could have a separate build for A
, B
, and C
. And then have a separate build logic build that you only include in C
. Which can also physically closed to C
in your folder structure.
I updated this sample on a branch to how I would imaging it to look now:
https://github.com/jjohannes/idiomatic-gradle/tree/composite-build
(Note that this will only work once gradle/gradle#6229 is fixed due to the cycle introduced by the end2end test setup. Which is a concern you might not have in your project. That will work in 6.8.)
Hi Jendrik,
Thank you for your reply and the time and effort that you've put into it, I appreciate it!
Your suggestion and direction that Gradle is moving into definitely make sense and the new features in 6.8 are badly needed.
For the time being though, as we need a working solution as of yesterday heh we'll start with the root project that comprises of several subprojects in one place. Hopefully once the features you mentioned are released and stable we'll revisit the structure again :)