What are the differences between Maven Jar Plugin and Maven Assembly Plugin?

JavaMavenPackaging

Java Problem Overview


Could somebody explain me the exactly differences between these two Maven plugins and when it is useful to work with one of these plugins?

Java Solutions


Solution 1 - Java

Maven jar plugin simply creates a jar files with all SOURCE files [.class files compiled from .java files] packed in it. However, a jar itself cannot be deployed as it generally has dependencies on 3rd party jar files or other library jar files which are needed to execute SOURCE jar file.

This is where Maven assembly plugin comes into picture. It creates a package of an extension of your choice like .zip, .tar, .gz which is a fully deployable package with all dependencies packed in it. You can also specify directory structure in assembly plugin which should be created when package is deployed on server.

So a assembly plugin is always used in combination with jar plugin.

Solution 2 - Java

Maven Jar plugin provides the capability to build and sign jars.The plugin use Maven Archiver to handle jar content and manifest configuration.
Maven Assembly Plugin is used to create all assemblies.

For More Info visit- http://maven.apache.org/plugins/maven-jar-plugin/<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; http://maven.apache.org/plugins/maven-assembly-plugin/

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
Questionuser2504767View Question on Stackoverflow
Solution 1 - JavaLokeshView Answer on Stackoverflow
Solution 2 - JavaAshrumochanView Answer on Stackoverflow