Select Page

Break Maven build when there is a dependency conflict

Break Maven build when there is a dependency conflict


  • You want to control #Maven during dependency resolution and break the build if some conditions are not met,
  • You want to detect dependencies conflict early during the build,
  • You want to avoid anybody in your team to use the dependency x in the version y

This is where the Maven Enforcer Plugin will assist you:

The Enforcer plugin provides goals to control certain environmental constraints such as #Maven version, JDK version and OS family along with many more standard rules and user created rules.

Add in your pom.xml the following to configure the plugin


There is a lot of standard rules that are already built in this plugin, the one that is interesting us for controlling dependencies is the dependencyConvergence – ensure all dependencies converge to the same version.

This rule requires that dependency version numbers converge. If a project has two dependencies, A and B, both depending on the same artifact, C, this rule will fail the build if A depends on a different version of C then the version of C depended on by B.

If during the resolution of artifact different version are found the build will fail with some nice logging infromation

Dependency convergence error for org.slf4j:slf4j-api1.6.1 paths to dependency are:  [ERROR] Dependency convergence error for org.slf4j:slf4j-api:1.6.1 paths to dependency are: 

You can use the standard dependencies management to enforce the version of org.slf4j you are coding/expecting.

In the same category, you can enforce dependencies in another way: force some dependencies to be never use thanks to the rule: bannedDependencies – enforces that excluded dependencies aren’t included. And if you’re are still not satisfied, you can even write your own rules!

0 0 votes
Article Rating
Notify of
Inline Feedbacks
View all comments


Would love your thoughts, please comment.x