A plugin that enables using the pack200 compression tool within Apache Maven2+ builds, simply and flexibly.
It was originally developed for optimizing download sizes and startup performance of Apache Pivot-based applications deployed via Java Webstart. It was developed carefully to provide a general solution for both signed and unsigned jars with pack200.
There is support for pack200 in the Webstart Maven Plugin, but the plugin's approach was too rigid and monolithic, assuming and dictating too much about how the build and deployment worked. This plugin grants full control over using the JDK's pack200 tool, allowing one to configure and bind executions to Maven build phases as needed directly while retaining the flexibility to package your application as you wish.
To use this plugin, you'll need:
- Apache Maven or a compatibile tool.
To build the plugin, simply run the following:
# Build and install the plugin
mvn install
You configure the plugin as you would any maven plugin, in the project object model file, pom.xml. At a minimum, you need to declare the plugin and bind it to your build's phases.
The following example configures the plugin to run twice:
- Pack and unpack, so crypto signatures are valid after decompression
- Pack the jar in final optimized form
Between these two phases, you normally configure jar signing.
<plugins>
<plugin>
<groupId>com.github.batkinson.plugins</groupId>
<artifactId>maven-pack200-plugin</artifactId>
<version>1.0.1</version> <!-- ensure this matches your version -->
<executions>
<execution>
<id>normalize-jars</id>
<phase>package</phase>
<goals>
<goal>pack</goal>
</goals>
<configuration>
<normalizeOnly>true</normalizeOnly>
</configuration>
</execution>
<execution>
<id>pack-jars</id>
<phase>verify</phase>
<goals>
<goal>pack</goal>
</goals>
<configuration>
<normalizeOnly>false</normalizeOnly>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
For a complete working example, take a peek at the OXD Form Designer Project. It builds an Apache Pivot-based application as a shaded (all dependencies included) signed and optimized jar.