mavendependenciesdependency-exclusion

Maven transitive dependencies with exclusion vs same transitive dependency without


I have this maven modules dependency hierarchy:

LibModel
+ Ext1
   - exclude(ext2)
LibApp
+ LibModel
+ Ext1 --- explicitly added without exclude this time
   + ext2

Other projects depends on LibModel and LibApp:

It really bothers me that depending on LibModel being explicitly listed as a dependency or otherwise being imported transitively through LibApp, the exclusion is applied on not. And I can't find information on that kind of dual import with and without exclusion.

=> is there a way to guaranty that if LibApp is a dependencies, Ext1 library is pulled full, disregarding LibModel being explicitly listed as a dependency?


Notes:


Solution

  • Not really. This is Maven dependency mediation. You can never guarantee certain transitive dependencies for a given library because other dependencies may override them.

    Possible things to think about: