1

Is there a maven plugin that will verify conflicting versions of transitive dependencies, ensuring that I'm not depending on different versions of the same artifact?

Ideally I would hook into the compile lifecycle, and it would fail the build if I'm importing both version X and Y of dependency A.

Wouter Lievens
  • 4,019
  • 5
  • 41
  • 66
  • Apparently this is a duplicate: http://stackoverflow.com/questions/3365201/how-do-i-get-maven-to-fail-when-conflicting-versions-of-the-same-artifact-are-re My apologies! – Wouter Lievens Oct 01 '14 at 08:01

1 Answers1

2

You can do it with maven-enforcer-plugin. Following configuration will cause a build to fail in case of conflicting versions:

 <build>
    <plugins>
      ...
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-enforcer-plugin</artifactId>
        <version>1.3.1</version>
        <executions>
          <execution>
            <id>enforce</id>
            <configuration>
              <rules>
                <DependencyConvergence/>
              </rules>
            </configuration>
            <goals>
              <goal>enforce</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
      ...
    </plugins>
  </build>

Here are more details:

http://maven.apache.org/enforcer/enforcer-rules/dependencyConvergence.html

Piotr Oktaba
  • 775
  • 1
  • 4
  • 14