'Maven exclusion for maven-toolchains-plugin
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
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>
Solution 1:[1]
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.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Kuldeep Jain |