Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What's the difference between Maven Jar Plugin and Maven Source Plugin?

Tags:

I was reading about how to create a jar file with Maven, but I saw some pom.xml files using Maven Source Plugin and others using Maven Jar Plugin.

In the Apache Maven Project page I found these descriptions:

Apache Maven JAR Plugin
This plugin provides the capability to build jars. If you like to sign jars please use the Maven Jarsigner Plugin.


Apache Maven Source Plugin
The Source Plugin creates a jar archive of the source files of the current project. The jar file is, by default, created in the project's target directory.


Reading these descriptions, I stayed in doubt about when use one or other plugin, and what are the differences or benefits, because I understood that both make the same thing.

like image 275
skyyyyy Avatar asked Jan 07 '18 13:01

skyyyyy


People also ask

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.

What is maven jar plugin?

The maven jar plugin provides the capability to build jars files, if you define that your project is packaged as a jar file, maven will call implicitely to this plugin. We don´t need to define it inside pom. xml it will be downloaded and executed when maven needs it.

What is plugin jar?

A plugin is most commonly a Java Jar file that contains a set of resource files (e.g., color tables) and/or Java class files.

What is source jar?

That sources jar is a jar that contains only the source code (the . java files) corresponding to the compiled artifact. It is useful to add it as a source attachment in your IDE, to publish the sources, etc. As it only contains sources, not compiled classes (. class files), it is of no use as a library dependency.


1 Answers

  • The Apache Maven JAR Plugin is used to build jar files containing .class files in order to distribute applications or libraries in bytecode format.

  • The Apache Maven Source Plugin is used to build jar files containing source files (.java files) in order to allow IDE to show the source code when debugging. This jar file is used in combination with the jar file containing .class files.

like image 187
Ortomala Lokni Avatar answered Sep 22 '22 12:09

Ortomala Lokni