S. O. Chaos S. O. Chaos - 11 months ago 68
Java Question

Building dependencies tree in Gradle

I have two projects which are not linked in any way. I need them to have the same dependency and this dependency is another project, which can be edited anytime. So dependency tree must look like that (well, I'm not really good in drawing):
enter image description here

How do I do that?

Answer Source

Here you have three projects. I think its better to keep these three projects in an archive, say EAR which is the root project. This will be easy to handle. So we can keep the root project name as Project. The structure will be: two independent projects, Project2 and Project3, with one common dependent Project1.

So we need to update the settings.gradle as:

rootProject.name = 'Project'
include 'Project2',':Project3'
include ':Project1'

And update the build.gradle of Project2 and Project3. Add the below code in both build.gradle file.

compile project(':Project1');

This will work.