Usage

This page contains some examples of how to use the mvndar plugin.

How to build a DAR file

To use the plugin, reference it from your project's pom.xml file.

<project>
  <modelVersion>4.0.0</modelVersion>
  <groupId>com.acme</groupId>
  <artifactId>mypublisher</artifactId>
  <version>1.23</version>
  <packaging>dar</packaging>
  ...
  <pluginRepositories>
    <pluginRepository>
      <id>push-repository</id>
      <url>http://download.pushtechnology.com/maven/</url>
    </pluginRepository>
  </pluginRepositories>
  ...
  <build>
    <plugins>
      ...
      <plugin>
        <groupId>com.pushtechnology.tools</groupId>
        <artifactId>dar-maven-plugin</artifactId>
        <version>1.3</version>
        <extensions>true</extensions>
      </plugin>
      ...
    </plugins>
  </build>
  ...
</project>

The <extensions>true</extensions> line is required so that Maven knows the plugin defines a new packaging type.

With the packaging type of the project set to dar as shown, the plugin will run whenever the project passes the "package" phase. You can execute it using the command below:

mvn package

The dar file will be generated in your project's target directory.

Default behaviour

Project output

The plugin will package the project's compiled classes and resources in the ext directory of the DAR file so they are available in the runtime classpath when it is deployed to a Diffusion server.

Dependencies

A subset of the project's dependencies will be added to the ext directory. The following rules are used to filter the dependencies.

  • The dependency type must be jar.
  • The dependency scope must be compile, runtime, or system. Any provided and test dependencies will not be included.
  • Optional dependencies are not included.
  • Transitive dependencies are not included. You must explicitly list dependencies you want included in your project's POM. See Issue #1.
  • A com.pushtechnology:diffusion-api dependency will not be included, since the server provides these classes.

Resources

Any content in etc, or html subdirectories of src/main/diffusion will be added to the DAR file.

You can customise the project output that is included or excluded by specifying a list of fileset patterns using <outputIncludes>/</outputInclude> or <outputExcludes>/</outputExclude>.

Similarly, you can filter the content from src/main/diffusion using <diffusionIncludes>/<diffusionInclude> or </diffusionExcludes>/</diffusionExclude>.

Manifest

A Diffusion-Version entry will be added to the DAR manifest.

The Diffusion-Version entry value defaults to 4.5.0. It can be changed using <minimumDiffusionVersion>.

<project>
  ...
  <build>
    <plugins>
      ...
      <plugin>
        <groupId>com.pushtechnology.tools</groupId>
        <artifactId>dar-maven-plugin</artifactId>
        <version>1.3</version>
        <extensions>true</extensions>
        <configuration>
          <minimumDiffusionVersion>6.0.0</minimumDiffusionVersion>
        </configuration>
      </plugin>
      ...
    </plugins>
  </build>
  ...
</project>

How to adjust other contents of the DAR archive

To handle archiving, the Maven DAR Plugin uses Maven Archiver 2.5. This allows control over the DAR manifest, whether the Maven pom.xml and pom.properties files are added to the DAR, and whether the DAR file is compressed.

For example, here's how to add implementation entries to the manifest.

<project>
  ...
  <build>
    <plugins>
      ...
      <plugin>
        <groupId>com.pushtechnology.tools</groupId>
        <artifactId>dar-maven-plugin</artifactId>
        <version>1.3</version>
        <extensions>true</extensions>
        <configuration>
          <archiver>
            <manifest>
              <addDefaultImplementationEntries>true</addDefaultImplementationEntries>
            </manifest>
          </archiver>
        </configuration>
      </plugin>
      ...
    </plugins>
  </build>
  ...
</project>