What is the use of maven shade plugin?

maven shade plugin:

maven-shade-plugin: It packages all dependencies into one uber-jar. It can also be used to build an executable jar by specifying the main class.

This plugin is particularly useful as it merges the content of specific files instead of overwriting them by Relocating Classes. This is needed when there are resource files that have the same name across the jars and the plugin tries to package all the resource files.

How to add Maven Shade Plugin::

<build> 
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<transformers>
<transformer implementation=”org.apache.maven.plugins.shade.resource.ManifestResourceTransformer”>
<mainClass>
path.to.MainClass
</mainClass>
</transformer>
</transformers>
<createDependencyReducedPom>
false
</createDependencyReducedPom>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>