I am depending on a library in my Maven project and I find that the library's JAR contains some packages which cause my application to fail. I believe the library should still work if I can somehow exclude these packages, but I would like to do this via Maven, rather than by hacking the JAR file myself. Is there a way to do this with Maven?
You can take a look at the maven-shade-plugin
. An example is shown in the official docs.
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>2.3</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<filters>
<filter>
<artifact>junit:junit</artifact>
<includes>
<include>junit/framework/**</include>
<include>org/junit/**</include>
</includes>
<excludes>
<exclude>org/junit/experimental/**</exclude>
<exclude>org/junit/runners/**</exclude>
</excludes>
</filter>
<filter>
<artifact>*:*</artifact>
<excludes>
<exclude>META-INF/*.SF</exclude>
<exclude>META-INF/*.DSA</exclude>
<exclude>META-INF/*.RSA</exclude>
</excludes>
</filter>
</filters>
</configuration>
</execution>
</executions>
</plugin>
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments