Ram
Ram

Reputation: 1497

Gradle dependecies: configuring multimodule build with interdependencies

I have complex project with about 55 modules in it. I am using Intellij Idea. So far I used to generate ANT build file using menu option from Intellij and make the build from command line. Recently Intellij has discontinued the feature.I am now moving to Gradle but facing issues with internal dependencies between modules. For example my project structure is somewhat like this:

Main Project

-- SubProject A

-- SubProject B

-- SubProject C

-- SubProject D

-- SubProject E

SubProject A depends upon B

SubProject B depends upon C

SubProject D depends upon C

SubProject E depends upon C

Main Project depends upon A,B,C,D,E

This is very simple representation but actually the dependencies are quite complex. I have referred to Gradle guide but it shows the multiproject dependencies which are simple. i.e.

Main Project

-- SubProject A

-- SubProject B

-- SubProject C

-- SubProject D

-- SubProject E

Main Project depends upon A,B,C,D,E

It is not showing how to configure interdependence between A,B,C,D,E themselves. I also cannot change the directory structure now. How do I go about configuring the project?

Upvotes: 0

Views: 108

Answers (1)

PrasadU
PrasadU

Reputation: 2438

you can refer to the siblings at subproject level directly, for ex in sub-projects a,b,d,e implementation project(':spc')

my example root settings.gradle include 'spa', 'spb', 'spc', 'spd', 'spe'

in sub projects a, b, d, e - build.gradle

dependencies {
    implementation project(':spc')
}

run output

-bash$ gradle :spa:build -m
:spc:compileJava SKIPPED
:spa:compileJava SKIPPED
:spa:processResources SKIPPED
:spa:classes SKIPPED
:spa:jar SKIPPED
:spa:assemble SKIPPED
:spa:compileTestJava SKIPPED
:spa:processTestResources SKIPPED
:spa:testClasses SKIPPED
:spc:processResources SKIPPED
:spc:classes SKIPPED
:spc:jar SKIPPED
:spa:test SKIPPED
:spa:check SKIPPED
:spa:build SKIPPED

BUILD SUCCESSFUL in 504ms

Upvotes: 1

Related Questions