Issue
We use ElasticSearch for our application. By a dependency in the pom file, we pull it in, do some configuration, and then repack it as a zip. This is the defined dependency in the maven pom file.
<dependency>
<groupId>org.elasticsearch.distribution.zip</groupId>
<artifactId>elasticsearch</artifactId>
<version>${elasticsearch-version}</version>
<type>zip</type>
</dependency>
The problem is that this zip contains 2 libraries that should be replaced.
- elasticsearch/lib/log4j-api-2.11.1.jar
- elasticsearch/lib/log4j-core-2.11.1.jar
The 2.17.0 jars should replace them. I thought to exclude the dependencies to the old one in maven and package the new ones into the ElasticSearch zip. But when I add an exclude to the dependence, the jars are still available in the packaged zip. So this is what I tried to remove:
What am I doing wrong?
Solution
The maven artifact does not specify any dependencies, the log4j jars are packaged in the elasticsearch artifact. So excluding dependencies will not work here. What you need to do is simply to remove/replace the files in between the unzipping and rezipping.
Answered By - kutschkem
Answer Checked By - Marilyn (JavaFixing Volunteer)