Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Dependency convergence error caused by maven-enforcer-plugin

The following is the error I see, what confused me is that why it would depends on 2 versions of my-engine dependency. One is 0.9.0-20180510.015454-2 and another is 0.9.0-SNAPSHOT.

Heres's the command I use:

mvn clean install -DskipTests

In the pom.xml, I specify the version as ${project.version} which here should be 0.9.0-SNAPSHOT. Could you anyone help me ? Thanks

[INFO] --- maven-enforcer-plugin:1.3.1:enforce (enforce) @ zeppelin-server ---
[WARNING]
Dependency convergence error for org.apache.hadoop:hadoop-client:2.7.3 paths to dependency are:
+-myproject:my-server:0.9.0-SNAPSHOT
  +-myproject:my-engine:0.9.0-20180510.015454-2
    +-org.apache.hadoop:hadoop-client:2.7.3
and
+-myproject:my-server:0.9.0-SNAPSHOT
  +-myproject:my-engine:0.9.0-SNAPSHOT
    +-org.apache.hadoop:hadoop-client:2.7.5

Here's the dependency in pom.xml

  <dependency>
    <groupId>myproject</groupId>
    <artifactId>my-zengine</artifactId>
    <version>${project.version}</version>
    <classifier>tests</classifier>
    <scope>test</scope>
  </dependency>

<dependency>
  <groupId>${project.groupId}</groupId>
  <artifactId>my-zengine</artifactId>
  <version>${project.version}</version>
</dependency>
like image 604
zjffdu Avatar asked Jul 28 '18 02:07

zjffdu


People also ask

What is dependency convergence error in Maven?

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 than the version of C depended on by B.

What does Maven enforcer plugin do?

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

How do you solve require upper bound dependencies error?

How to fix require upper bound dependencies error. If that artifact is already declared in pom. xml, update the version in the pom. xml to the newest version listed in the output from maven-enforcer-plugin.

What is Maven Dependencymanagement?

What Is Maven Dependency Management? Dependency management in Maven allows teams to manage dependencies for multi-module projects and applications. These can consist of hundreds or even thousands of modules. Using Maven can help teams define, create, and maintain reproducible builds.


1 Answers

You could fix this in one of two ways, either choose to ignore it

mvn clean install -Denforcer.fail=false

or add both wildcard exclusion and exclusion for every dependency that caused the enforcer in the first place as follows.

<dependency>
<groupId>org.apache.maven.plugin-tools</groupId>
<artifactId>maven-plugin-tools-api</artifactId>
<version>2.5.1</version>
<exclusions>
    <exclusion>
        <groupId>*</groupId>
        <artifactId>*</artifactId>
    </exclusion>
    <exclusion>
        <groupId>org.apache.hadoop</groupId>
        <artifactId>hadoop-client</artifactId>
    </exclusion>
</exclusions>

like image 142
Amos Kosgei Avatar answered Sep 22 '22 01:09

Amos Kosgei