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!

About The Author

Cédric Walter

I worked with various Insurances companies across Switzerland on online applications handling billion premium volumes. I love to continuously spark my creativity in many different and challenging open-source projects fueled by my great passion for innovation and blockchain technology.In my technical role as a senior software engineer and Blockchain consultant, I help to define and implement innovative solutions in the scope of both blockchain and traditional products, solutions, and services. I can support the full spectrum of software development activities, starting from analyzing ideas and business cases and up to the production deployment of the solutions.I'm the Founder and CEO of Disruptr GmbH.