Handling Mutli-Project Dependecies

Hi,

I would appreciate your help with understanding what is the correct approach for multi-project dependencies.

Say I have 3 components A, B & C. A is a multi project publishing A-first.jar & A-second.jar (published to maven repo), B & C are single project with the following dependencies:
C–>B:1.0.0, A-first:1.0.0
B–>A-second:3.0.0
All dependencies are external dependencies (i.e. repo artifacts) and not project dependencies.

So now when building C, I will get a dependency on A-first:1.0.0 (direct dependency) and on A-second:3.0.0 (transitive dependency).
This is a situation I want to avoid, I want to have all A artifacts with the same version (when using a multi-project component I want to make sure I use all of its artifacts from the same version).

Does gradle knows how to deal with such situation automatically (i.e. resolve multi-project artifacts dependecies by aligning its version)?

If not, what is the best practice for such scenario?

Thanks,
Assaf.

This could be done using a custom resolution strategy. You’ll likely need two sweeps over the incoming dependencies

First sweep: Find the max version for each "group"
Second sweep: Force the max version for each applicable dependency

1 Like