I am using the maven-shade-plugin to create a single executable jar.
I would expect the plugin to create a single jar (foo.jar
) in the target directory.
However it will also create two other jars: original-foo.jar
and foo-shaded.jar
.
Why does it create those files and how do I disable this behavior?
(We have another project using that plugin, where those files are not created. Therefore I am pretty sure it is possible to disable those, but I could not see the difference.)
This plugin provides the capability to package the artifact in an uber-jar, including its dependencies and to shade - i.e. rename - the packages of some of the dependencies.
Shading is a process where a dependency is relocated to a different Java package and copied into the same JAR file as the code that relies on that dependency. The main purpose of shading is to avoid conflicts between the versions of dependencies used by a library and the versions used by the consumers of that library.
plug-in is a software component that adds a specific feature to any computer program.It specially use to customize any computer program. But . jar file is a java executable file which can only run on an environment which Java installed.
The plugin maven-shade-plugin by using outputFile is bypasing other behaviours:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
...
<configuration>
<outputFile>/tmp/watchdog.jar</outputFile>
</configuration>
</plugin>
More info in: https://maven.apache.org/plugins/maven-shade-plugin/shade-mojo.html#outputFile
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With