Maven exclusion for maven-toolchains-plugin

661 views Asked by At

In our module say XYZ We included a dependency for maven toolchains plugin to have our Jenkins build run with a specific JDK version. But once we included this toolchain dependency it further bring in lot of other dependencies (See screenshot below) when we include XYZ module as a dependency in another project.

Some of these dependencies which came due to toolchain like slf4j-jdk14-1.5.6.jar and slf4j-nop-1.5.3.jar are causing issues like SLF4J: Class path contains multiple SLF4J bindings. when we deploy the application.

Maven dependency we added for toolchain plugin

<dependencies>
    <dependency>
      <groupId>org.apache.maven.plugins</groupId>
      <artifactId>maven-toolchains-plugin</artifactId>
      <version>1.1</version>
    </dependency>
</dependencies> 

Dependency tree of maven-toolchains-plugin

enter image description here

So, my question is if I exclude org.apache.maven:maven-toolchain or org.apache.maven:maven-core (as shown below) while adding the toolchains plugin dependency in XYZ would it cause any issue with respect to my other dependencies

<dependencies>
    <dependency>
      <groupId>org.apache.maven.plugins</groupId>
      <artifactId>maven-toolchains-plugin</artifactId>
      <version>1.1</version>
      <exclusions>
        <exclusion>
          <groupId>org.apache.maven</groupId>
          <artifactId>maven-core</artifactId>
        </exclusion>
      </exclusions>
    </dependency>
</dependencies>
1

There are 1 answers

0
Kuldeep Jain On BEST ANSWER

This answer is based on @khmarbaise's comments above.

Having a dependency to maven-toolchains-plugin was simply wrong. I went on to check this documentation: Guide to Using Toolchains that too does not talk about adding the dependency.

I followed a company internal confluence page which mentioned to include it which was wrong.