Joomla Extensions Demo

Support

Do not submit a bug report if you need technical support or have questions.

Forums

Post your suggestions ask for help in the community forums

Contact Me

Missing images/links, any comments, suggestions, need help? Contact me

Skype

Need desperately help?
Skype Me™! But dont abuse of it!

Break Maven build when there is a dependency conflict

apache_maven_thumb

Scenarios

  • 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

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-enforcer-plugin</artifactId>
    <version>1.0</version>
    <executions>
        <execution>
            <id>enforce</id>
            <configuration>
                <rules> 
                    <DependencyConvergence />
                </rules>
            </configuration>
            <goals> 
                <goal>enforce</goal>
            </goals>
        </execution>
    </executions>
</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:
+-org.myorg:my-project:1.0.0-SNAPSHOT
  +-org.slf4j:slf4j-jdk14:1.6.1
    +-org.slf4j:slf4j-api:1.6.1
and
+-org.myorg:my-project:1.0.0-SNAPSHOT
  +-org.slf4j:slf4j-nop:1.6.0
    +-org.slf4j:slf4j-api:1.6.0

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!

You might also like:
Apache Maven copy local file to a remote server server using
39 days ago
Apache Maven copy local file to a remote server server using
I will show you in an Apache Maven configuration file how to copy files to server each time the pa
Apache M2Eclipse: Get rid of Duplicate resources when openin
45 days ago
Apache M2Eclipse: Get rid of Duplicate resources when openin
In this small post, I’ll show you how to remove duplicated resources in the Open Resource view o
Apache Maven 3 Cookbook
187 days ago
Apache Maven 3 Cookbook
  First a big thanks to Packt Publishing for having sent me this book to review! I did enj
Apache Maven 3 Cookbook Review
233 days ago
Apache Maven 3 Cookbook Review
Thanks to Packt Publishing for having sent me this book to review. I will publish a review in the
List conflicting dependencies in the Maven reactor
349 days ago
List conflicting dependencies in the Maven reactor
The Maven Dependency Plugin among other things include a dependency:analyze-duplicate The depe
OSGi-Bundle with the Maven-Bundle-Plugin
350 days ago
OSGi-Bundle with the Maven-Bundle-Plugin
OSGi (Open Service Gateway Initiative) is a Java framework for developing and deploying modu
Apache Maven Cargo deploy with Tomcat 7
360 days ago
Apache Maven Cargo deploy with Tomcat 7
Following the post about Deploy to Tomcat 6 using Maven, here is a ready to use example with the
Speeding up Apache Maven Builds
606 days ago
Speeding up Apache Maven Builds
The obvious things to do first in no particular order Use a better build server, CPU power is c
blog comments powered by Disqus
Category: Apache Maven

Donations

Thank You for supporting my work
Subscribe to me on YouTube

Latest Articles

  • In this series of post I will outline some common techniques to help Joomla extensions development. As you know Jooml... ...
  • CedTag  has been updated to version 2.5.3 and correct a lot of bugs and contains some nice features. CedTag is t... ...
  • CedThumbnails has been updated to version 2.5.5 and contains 1 new features for both Joomla 1.7 and Joomla 2.5. For ex... ...
  • CedSmugmug  has been updated to version 2.5.2 and correct some bugs and contains some nice features. CedSmugmug&... ...
  • If you want an extra gigabyte of storage on your Dropbox account, the online cloud service invites you to compete in i... ...

Subscribe

Latest Comments

Popular Posts

rockettheme advertisement

dropbox logo

Help Us & Leave Feedback!

  • Do you have an excellent article idea you would like to read about here? Share it!
  • Do you have some interesting tips how we could improve our site?
  • Something missing here? Help us make this blog a better place, leave feedback!
We would love to hear from you! Be active! Write us now!