7.3 Adding the par plugin

Thorsten Maus contributed a Maven plugin to SpringSource (see Section A.2, “Documentation”) that builds a PAR file from a list of dependencies. In this step the Maven par plugin is added to properly build a PAR artifact type.

In the <build><plugins>…</plugins></build> section, add a plugin declaration for the par plugin.

<plugin>
<groupId>org.apache.maven.plugins</groupId>
  <artifactId>maven-par-plugin</artifactId>
  <version>1.0.0.RELEASE</version>
  <configuration>
    <applicationSymbolicName>greenpages</applicationSymbolicName>
    <applicationDescription>GreenPages Sample Application</applicationDescription>
  </configuration>
</plugin>

Declare the list of bundles to be packaged in the PAR as dependencies of the PAR project.

<dependency>
  <groupId>com.springsource.dmserver</groupId>
  <artifactId>greenpages.app</artifactId>
  <version>${project.version}</version>
</dependency>
<dependency>
  <groupId>com.springsource.dmserver</groupId>
  <artifactId>greenpages.jpa</artifactId>
  <version>${project.version}</version>
</dependency>
<dependency>
  <groupId>com.springsource.dmserver</groupId>
  <artifactId>greenpages.db</artifactId>
  <version>${project.version}</version>
</dependency>
<dependency>
  <groupId>com.springsource.dmserver</groupId>
  <artifactId>greenpages.web</artifactId>
  <version>${project.version}</version>
  <type>war</type>
</dependency>

Now, run the following command.

mvn clean package

This command will now complete successfully and build a PAR into target/. Proceed to the next step.

[INFO] [par:par]
[INFO] assembling artifacts for par package
[INFO] greenpages
[INFO] artifact greenpages.app is copied with fully qualified name
       com.springsource.dmserver.greenpages.app-2.0.0.SNAPSHOT
[INFO] artifact greenpages.jpa is copied with fully qualified name 
       com.springsource.dmserver.greenpages.jpa-2.0.0.SNAPSHOT
[INFO] artifact greenpages.db is copied with fully qualified name 
       com.springsource.dmserver.greenpages.db-2.0.0.SNAPSHOT
[INFO] artifact greenpages.web is copied with fully qualified name 
       com.springsource.dmserver.greenpages.web-2.0.0.SNAPSHOT
[INFO] added com.springsource.dmserver.greenpages.app-2.0.0.SNAPSHOT.jar
[INFO] added com.springsource.dmserver.greenpages.db-2.0.0.SNAPSHOT.jar
[INFO] added com.springsource.dmserver.greenpages.jpa-2.0.0.SNAPSHOT.jar
[INFO] added com.springsource.dmserver.greenpages.web-2.0.0.SNAPSHOT.jar