Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the purpose of Mavens dependency declarations classifier property?

I have a pom.xml file and in that i see that their are 3 dependencies referenced for same <artifactId> the difference are in tags

<classifier>sources</classifier> <classifier>javadoc</classifier> 

I have deleted the dependencies that had the SOURCES/JAVADOCand only kept one dependency. I tested my application and every thing work fine.

What is the purpose of using this classifier tag? and why i need to duplicate dependencies twice for adding <classifier> tag with SOURCES/JAVADOC .

<dependency>    <groupId>oauth.signpost</groupId>    <artifactId>signpost-commonshttp4</artifactId>    <version>1.2.1.2</version>    <type>jar</type>    <scope>compile</scope> </dependency>   <dependency>    <groupId>oauth.signpost</groupId>    <artifactId>signpost-commonshttp4</artifactId>    <version>1.2.1.2</version>    <type>jar</type>       ***<classifier>javadoc</classifier>***    <scope>compile</scope> </dependency> <dependency>    <groupId>oauth.signpost</groupId>    <artifactId>signpost-commonshttp4</artifactId>    <version>1.2.1.2</version>    <type>jar</type>    ***<classifier>sources</classifier>***    <scope>compile</scope> </dependency>  
like image 851
pushya Avatar asked Jan 03 '14 17:01

pushya


People also ask

What is the use of classifier in Maven?

The classifier distinguishes artifacts that were built from the same POM but differ in content. It is some optional and arbitrary string that - if present - is appended to the artifact name just after the version number.

What is the use of dependencies in Maven?

In Maven, a dependency is just another archive—JAR, ZIP, and so on—which our current project needs in order to compile, build, test, and/or run. These project dependencies are collectively specified in the pom.

What is Maven artifact classifier?

A Maven artifact classifier is an optional and arbitrary string that gets appended to the generated artifact's name just after its version number. It distinguishes the artifacts built from the same POM but differing in content.


1 Answers

The classifier distinguishes artifacts that were built from the same POM but differ in content. It is some optional and arbitrary string that - if present - is appended to the artifact name just after the version number.

Source

like image 76
Biswajit Avatar answered Oct 13 '22 05:10

Biswajit