7.4 Adding the par plugin
Prev | 7. Automated Build | Next

## 7.4 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</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/`:

    [INFO] Scanning for projects...
    			[INFO] ------------------------------------------------------------------------
    			[INFO] Building GreenPages PAR
    			[INFO]    task-segment: [clean, package]
    			[INFO] ------------------------------------------------------------------------
    			[INFO] [clean:clean {execution: default-clean}]
    			[INFO] [resources:resources {execution: default-resources}]
    			[INFO] [par:par {execution: default-par}]
    			[INFO] Assembling Artifacts for PAR '…/start/greenpages/target/greenpages-2.3.0.RELEASE.par'
    			[INFO]   Added 'greenpages.app.jar'
    			[INFO]   Added 'greenpages.jpa.jar'
    			[INFO]   Added 'greenpages.db.jar'
    			[INFO]   Added 'greenpages.web.war'
    			[INFO] [com.springsource.bundlor.:transform {execution: bundlor}]
    			[INFO] Ignored project with non-bundle packaging: [par]
    			[INFO] ------------------------------------------------------------------------
    			[INFO] BUILD SUCCESSFUL
    			[INFO] ------------------------------------------------------------------------

Proceed to the next step.

Prev | Up | Next
7.3 Create POM | Home | 7.5 Adding the dependency plugin