The first thing to do is to create a new pom.xml file for the shared library. A simple example can look like this...
Maven POM
<?xml version="1.0" encoding="UTF-8" ?>
<project xmlns="http://maven.apache.org/POM/4.0.0">
<modelVersion>4.0.0</modelVersion>
<groupId>net.igorkromin</groupId>
<artifactId>MySharedLib1</artifactId>
<version>1.0.0</version>
<name>${project.artifactId}</name>
<packaging>war</packaging>
</project>
That of course is not enough but the important part to take away from the snippet above is the package is set to war. This means we will be using maven-war-plugin to create the package, this is configured a little bit later on.
Before continuing I like to set up a number of properties to make the pom.xml file more portable. In this case I define all the key elements I would like to configure for my shared library by adding a properties section to the pom.xml file...
Maven POM
<properties>
<sharedlib.name>net.igorkromin.sharedlib1</sharedlib.name>
<sharedlib.vendor>Igor Kromin</sharedlib.vendor>
<sharedlib.spec.version>1.0</sharedlib.spec.version>
<sharedlib.impl.version>1.0.0</sharedlib.impl.version>
</properties>
Now with those properties set I I can define the configuration for maven-war-plugin. It looks a little like this...
Maven POM
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.6</version>
<configuration>
<failOnMissingWebXml>false</failOnMissingWebXml>
<archive>
<compress>true</compress>
<manifestEntries>
<Specification-Title>${sharedlib.name}</Specification-Title>
<Specification-Version>${sharedlib.spec.version}</Specification-Version>
<Implementation-Title>${sharedlib.name}</Implementation-Title>
<Implementation-Version>${sharedlib.impl.version}</Implementation-Version>
<Implementation-Vendor>${sharedlib.vendor}</Implementation-Vendor>
<Extension-Name>${sharedlib.name}</Extension-Name>
</manifestEntries>
</archive>
</configuration>
</plugin>
</plugins>
</build>
The configuration is fairly straight forward, all it does is set failOnMissingWebXml to false so that the packager ignores the fact that we don't have a deployment descriptor (since it is not needed in this case). It sets up the manifest file in a way that WebLogic would recognise.
Ok so far so good but where are the JAR files that make up the shared library? This is configured through dependencies. Assuming you already have the JAR file either in your local Maven repository or in the remote repository, simply define a compile scope dependency and the JAR file will be included automatically. It is possible to have multiple JARs in the final WAR file simply by defining multiple dependencies like this.
Maven POM
<dependencies>
<dependency>
<groupId>net.igorkromin</groupId>
<artifactId>SharedJar1</artifactId>
<version>1.0.0</version>
<scope>compile</scope>
</dependency>
</dependencies>
Now just put all that together into one pom.xml file and you're good to go.
-i