I have read:
And the conclusion that I have is that there is no way to exclude a particular dependency that is inherited from a parent pom. I'm using maven and the parent pom isn't editable.
So, I thought about excluding the jar itself, of the dependency, right before it got packaged into the target jar.
My parent pom is `sdk-java-starter-parent` that comes from an internal library.
<parent>
<groupId>abc.def.xyz</groupId>
<artifactId>sdk-java-starter-parent</artifactId>
<version>6.1.0.4</version>
</parent>
that pom declares log4-1.2.7
dependency, which I would like to exclude and not to import to my project at all.
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.17</version>
</dependency>
If I would import the parent pom directly from spring's group, I could use spring-boot-maven-plugin
in order to exclude it there.
But because i'm importing the parent pom from an internal library, there is no use or possibility to use that plugin.
I thought about using maven-shader plugin and other re-packing plugins in order to 'shade' the jar right before it gets packed:
<excludes>
<exclude>log4j-1.2.17.jar</exclude> (tried also `**/log4j-1.2.17.jar`)
</excludes>
but it did not work as well.
I have tried with <dependencyManagement>
and it doesn't fit because I don't want to override the version, I just want to remove the whole dependency. to entirely exclude it or remove the jar of it.
I'm clueless to be honest, i'll be glad to hear some ideas how would u suggest me to do it, if it's possible at all.
What are my other options if it's not possible? How can I avoid receiving that log4j jar?
The final app is a docker container consisting of JARs.
The plugins that are being used are:
- maven-jar-plugin
- maven-surefire-plugin
- docker-maven-plugin
- swagger-maven-plugin
I'm not sure which one of these is responsible for building the app and for the jar packacing.
Thanks.