Home > other >  maven dependency managment and version change of transitive dependency
maven dependency managment and version change of transitive dependency

Time:10-20

How to safely manage with such a problem:

In maven we have 2 libs (A with version 20, B with version 30) that depends on C (1.0 and 1.1 respectively). We get jar hell in target libs

*--A20--C1.0
\--B30--C1.1

Then I add dependencyManagment section and force C version to 1.1. It works as expected.

*--A20--C1.1 (not C1.0)
\--B30--C1.1

After several months, we decide to upgrade A to version 50. Now it depends on C version 2.0. But project still uses 1.1 due to dependencyManagement. It's a problem now

*--A50--C1.1 (not C2.0 as needed)
\--B30--C1.1

The question is: is it possible to override transitive dependency and this override will work only if version of transitive dependency match the version we set? Otherwise this override will be ignored and we'll see an error (with help of maven-enforcer plugin, for instance) I wonder if we have some plugin to check this case?

CodePudding user response:

No.

I understand your use case, but I do not see anything in Maven to produce the result you want.

  • Related