Tuesday, September 30, 2014

Maven Tips

  • Maven Overlays are used to share common resources across multiple web applications. The dependencies of a WAR project are collected in WEB-INF/lib, except for WAR artifacts which are overlayed on the WAR project itself.
  • Maven Overlays can be achived simply by using adding dependency
  • If you want more control on  Overlay, like inclusion/exclusion/target overlay location then you need to use maven-war-plugin and overlay tag in configuration
  • Maven Overlays are applied with a first-win strategy (hence if a file has been copied by one overlay, it won't be copied by another)
  • In Maven overlay configuration by default, the source of the project (a.k.a the current build) is added first (e.g. before any overlay is applied). The current build is defined as a special overlay with no groupId, artifactId. If overlays need to be applied first, simply configure the current build after those overlays.
  • To support external dependency not available in maven repository, for ex: any paid lib. GroupID and ArtifactID should be same, scope should be system and systempath should be relative to project location.
       <dependency>
         <groupId>ojdbc14</groupId>
         <artifactId>ojdbc14</artifactId>
         <scope>system</scope>
         <version>1.0</version>
         <systemPath>${basedir}\jar\ojdbc14.jar</systemPath>
      </dependency>

Sources: http://maven.apache.org