Search code examples
javamavendependency-management

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> 

Solution

  • 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