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:
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:
Add a dependencyManagement entry for Ext1
Add an explicit dependency on Ext1
Avoid the exclusion. It is usually not a problem if LibModel has more dependencies than necessary at compile time if those dependencies are necessary at runtime.