0

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>
cb4
  • 6,689
  • 7
  • 45
  • 57
Kuldeep Jain
  • 8,409
  • 8
  • 48
  • 73
  • 1
    Having a dependency to maven-toolchains-plugin is simply wrong. No need to run toolchains. – khmarbaise Sep 18 '18 at 17:43
  • Related to Jenkins. If you like to build with different JDK than Jenkins is Running you have to go via Freestyle Job Type or using the pipeline.... – khmarbaise Sep 18 '18 at 17:46
  • @khmarbaise, After looking at your suggestion to not add dependency for `maven-toolchains-plugin` went on to check the this https://maven.apache.org/guides/mini/guide-using-toolchains.html that also does not talk about adding the dependency. I followed a company internal confluence page which mentioned to include it which was wrong. After removing the dependency it is good now. Thanks for your comment. – Kuldeep Jain Sep 19 '18 at 23:03
  • Glad to help. Furthermore If you are unsure please consult the users mailing of Apache Maven and don't rely on internal docs etc. which (unfortunately to say) are usually simply wrong... – khmarbaise Sep 20 '18 at 05:19

1 Answers1

0

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.

Kuldeep Jain
  • 8,409
  • 8
  • 48
  • 73