Aggregation jars make development simpler and wars smaller

We use aggregation projects in order to:
– simplify the POM structure for our modules by reducing the number of dependencies
– releiving module developers of any concern about versions of common libraries
– centralize control over versions
– simplify upgrading of versions of third party tools
– reducing the size of war files
– quicker builds
– smaller transfers to servers
– faster application startup
– avoiding version conflicts at run-time.

We build the aggregated jars with the standard Maven plug-ins.
For example, we build a single Spring-Hibernate-MySQL jar that includes all the classes required to use all three of these packages.
We drop this into the Tomcat shared library so that it is set as “provided” in each of our modules which really reduces the size of the war files.
We do the same thing for the utility libraries (mostly Apache) that we use.
Also for JasperReports.
They are all structured in the same way.
I have attached the pom for JasperReports since it is short and shows a first level aggregation
The second pom shows how we aggregate lower level libraries to make a single library “spring-hibernate-mysql-tomcat” from “hibernate-mysql-tomcat” and “spring” aggregations.

This hierarchical approach makes it easier to manage the versions in the lower level.

Notes:
1) Just using the maven-assembly-plugin. Shade should work as well but we have never used it.
2) We carefully exclude libraries that are provided elsewhere.

<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
  <groupId>com.artifact_software.lms</groupId>
  <artifactId>lms-pom-jasper</artifactId>
  <packaging>pom</packaging>
  <name>lms Pom for Jasper</name>
  <version>1.9.1</version>
    <properties>
  	<jasperreports.version>3.7.4</jasperreports.version>
		<jfreechart.version>1.0.12</jfreechart.version>
		<jcommon.version>1.0.15</jcommon.version>
		<itext.version>2.1.0</itext.version>
		<jdtcore.version>3.1.0</jdtcore.version>
		<bouncycastle.version>136</bouncycastle.version>
		</properties>
  <description>dependency pom for projects requiring Jasper</description>
  <parent>
  	<artifactId>lms-pom-master</artifactId>
  	<groupId>com.artifact_software.lms</groupId>
  	<version>1.9.1</version>
  </parent>
  <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-assembly-plugin</artifactId>
            </plugin>
        </plugins>
  </build>
  <dependencies>
  	<dependency>
  		<groupId>net.sf.jasperreports</groupId>
  		<artifactId>jasperreports</artifactId>
  		<version>${jasperreports.version}</version>
  		<exclusions>
  			<exclusion>
  				<artifactId>commons-logging</artifactId>
  				<groupId>commons-logging</groupId>
  			</exclusion>
  			<exclusion>
  				<artifactId>commons-beanutils</artifactId>
  				<groupId>commons-beanutils</groupId>
  			</exclusion>
  			<exclusion>
  				<artifactId>commons-collections</artifactId>
  				<groupId>commons-collections</groupId>
  			</exclusion>
  			<exclusion>
  				<artifactId>commons-digester</artifactId>
  				<groupId>commons-digester</groupId>
  			</exclusion>
  			<exclusion>
  				<artifactId>xml-apis</artifactId>
  				<groupId>xml-apis</groupId>
  			</exclusion>
  			<exclusion>
  				<artifactId>itext</artifactId>
  				<groupId>com.lowagie</groupId>
  			</exclusion>
  			<exclusion>
  				<artifactId>jdtcore</artifactId>
  				<groupId>eclipse</groupId>
  			</exclusion>
  		</exclusions>
  	</dependency>
  	<dependency>
  		<groupId>jfree</groupId>
  		<artifactId>jfreechart</artifactId>
  		<version>${jfreechart.version}</version>
  	</dependency>
  	<dependency>
  		<groupId>bouncycastle</groupId>
  		<artifactId>bcprov-jdk14</artifactId>
  		<version>${bouncycastle.version}</version>
  	</dependency>
  	<dependency>
  		<groupId>bouncycastle</groupId>
  		<artifactId>bcmail-jdk14</artifactId>
  		<version>${bouncycastle.version}</version>
  	</dependency>
  	<dependency>
  		<groupId>eclipse</groupId>
  		<artifactId>jdtcore</artifactId>
  		<version>${jdtcore.version}</version>
  	</dependency>
  </dependencies>
</project>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>	<groupId>com.artifact_software.util</groupId>
<artifactId>util-pom-spring-hibernate-mysql-tomcat</artifactId>
<packaging>pom</packaging>
<name>Spring, Hibernate, MySQL-Tomcat</name>
<version>1.0</version>
<parent>
	<artifactId>util-pom-master</artifactId>
	<groupId>com.artifact_software.util</groupId>
	<version>1.0</version>
</parent>

<description>Spring, MySQL, Hibernate, Tomcat configuration</description>

<build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-assembly-plugin</artifactId>
            </plugin>
        </plugins>
</build>

<dependencies>
	<dependency>
		<groupId>com.artifact_software.util</groupId>
		<artifactId>util-pom-hibernate-mysql-tomcat</artifactId>
		<version>${util.version}</version>
		<type>pom</type>
	</dependency>
	<dependency>
		<groupId>com.artifact_software.util</groupId>
		<artifactId>util-pom-spring</artifactId>
		<version>${util.version}</version>
		<type>pom</type>
	</dependency>
</dependencies>
</project>
Tagged with: ,