Member-only story
Maven shade plugin is mainly used to create an `uber` jar that can be run as a single executable jar or loaded as a single jar instead of adding independent libraries as classpath artifacts to a java process. Uber jar is another term for a jar that contains everything. In regular scenarios, Maven uses other dependencies defined in the pom.xml to compile and builds a final artifact that contains the classes and its resources only. With the maven shade plugin or uber jar approach, maven takes all dependencies(defined with compile scope) and extract all the contents of those dependencies and create a new jar with the classes and resources of the artifact itself.
In this article, I am going to go over some things to keep in mind while creating shaded/uber jars. First of all, create uber jars only as final artifacts that need to be run as executable.
Maven shade plugin sample:
<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>*:*</artifact>
<excludes>
<exclude>META-INF/*.SF</exclude>
<exclude>META-INF/*.DSA</exclude>
<exclude>META-INF/*.RSA</exclude>
</excludes>
</filter>
</filters>
<transformers>
<transformer…