Difference between maven plugins ( assembly-plugins , jar-plugins , shaded-plugins)

ilovejavaAJ picture ilovejavaAJ · Jul 24, 2016 · Viewed 17.6k times · Source

I am a beginner in maven and now I'm confused with the difference between these maven plugins. Is these all create jar files? now my questions are

  1. what's the difference between the jar created in each plugins.( assembly plugin, jar-plugin, shaded plugin)

  2. The purpose of each plugin. ( assembly, jar plugin, shaded plugin )

  3. I know even without specifying any of these plugins once type mvn package there will be a jar output. What is the difference of the output jar without these plugins and the output jar with these plugins?. TIA

Answer

secfree picture secfree · Apr 17, 2017
  1. maven-jar-plugin: This plugin provides the capability to build and sign JARs. But it just compiles the java files under src/main/java and src/main/resources/. It doesn't include the dependencies JAR files.
  2. maven-assembly-plugin: This plugin extracts all dependency JARs into raw classes and groups them together. It can also be used to build an executable JAR by specifying the main class. It works in project with less dependencies only; for large project with many dependencies, it will cause Java class names to conflict.
  3. 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 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 together.

Refer: comparison:maven plugin jar,assembly,shade