Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Disable additional jars for the maven-shade-plugin

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.)

like image 268
michas Avatar asked May 20 '15 12:05

michas


People also ask

What is shaded jar in Maven?

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.

What does shaded jar mean?

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.

What is the difference between jar and plugin?

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.


1 Answers

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

like image 177
Francisco Ferri Avatar answered Sep 28 '22 07:09

Francisco Ferri