Saturday, October 6, 2012

Maven Tips


  • When we include a jar dependency in pom.xml. That jar may intern depend on other jars and maven resolve it and loads all jars whether those are directly indicated as dependent jars or indirectly within dependent jars. Now if we have some latest version or any other reason and want to exclude a particular jar to be included as dependent then maven provides "exclusions" element tag. Its sample usage is given below:
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
<version>4.1.7.Final</version>
<scope>provided</scope>
<exclusions>
      <exclusion>
         <groupId>org.antlr</groupId>
         <artifactId>antlr</artifactId>
      </exclusion>
   </exclusions>
</dependency>

In above example, exclusions tag used to exclude antlr jar file to be included as dependent jar for hibernate

continued...

No comments: