Detect Maven Dependency Mediation

As of Maven 2.0.9 a new feature was added to Maven called dependency mediation.
Dependency mediation is the technique used by Maven to resolve your project dependencies in the specific case when a dependency occurs multiple times in your dependency tree.
Usually this occurs on transitive dependencies linked through the dependencies of your project.
In these cases mediation will be performed using the nearest win-strategy.
In short this strategy means that Maven will use the version declared in the pom.xml that is closest to your project pom.xml.
Hence, no in-depth intelligence is used to resolve the dependency conflict.
Actually, I can’t really think of a conflict resolve strategy that would really solve this problem.

Any strategy I can think of has the hazard of linking incompatible dependencies in to your project.
Using Maven version ranges can ofcourse resolve compatibility between artifacts, but this also requires you to establish a compatibility matrix of your dependencies. A pretty tedious task if you ask me.

Now this whole mediation feature might sound like a very undesirable feature, but it’s not!
With this feature you can now at least be made aware of any dependency conflicts in your project dependencies.
When you build your project using the -X switch, Maven will output all mediations (and a lot more) that have been performed.

Now, wouldn’t it be cool if there was a maven-plugin to detect mediation?
JDriven took the liberty of extending Apache’s dependency plugin with such a feature and share it with you.
Continue reading