Instructions for Maven 2.1 users

Last change-log entry: 2010-May-11

Basic configuration

The project's packaging type, and the scope of the dependencies to be liberated from, should be set as in the following example:

<project>
  ...
  <packaging>jar</packaging>
  ...
  <dependencies>
    <dependency>
      <groupId>org.scala-lang</groupId>
      <artifactId>scala-library</artifactId>
      <version>${scala.version}</version>
      <scope>provided</scope>
    </dependency>
    <dependency>
      <groupId>org.scala-lang</groupId>
      <artifactId>scala-swing</artifactId>
      <version>${scala.version}</version>
      <scope>provided</scope>
    </dependency>

The plug-in should be referenced and configured with the desired entryPoints, as in the following example; note that the latest version (currently 1.2) will be used by default:

  ...
  <build>
    ...
    <plugins>
      <plugin>
        <groupId>com.lafros.maven.plugins</groupId>
        <artifactId>maven-proguard-plugin</artifactId>
        <!--version>1.2</version>-->
        <executions>
          <execution>
            <goals>
              <goal>liberate</goal>
            </goals>
            <configuration>
              <entryPoints>
                <param>com.lafros.gui.demo.alerts.app</param>
                <param>com.lafros.gui.app.Applet</param>
              </entryPoints>
              ...
            </configuration>
          </execution>
        </executions>
      </plugin>

Setting other proguard:liberate parameters is optional - see the section which follows for examples of when to do this.

Override the default value of the jar:jar classesDirectory parameter, so as to create the jar using classes obtained from proguard:liberate's liberatedClassesDirectory:

    ...
    <plugins>
      <plugin>
        <artifactId>maven-jar-plugin</artifactId>
        <configuration>
          ...
          <classesDirectory>${project.build.directory}/liberated-classes</classesDirectory>

Finally, tell Maven where the plug-in is to be found:

  ...
  <pluginRepositories>
    <pluginRepository>
      <id>lafros.com</id>
      <url>http://lafros.com/m2arts</url>
    </pluginRepository>
  </pluginRepositories>

To create the liberated jar, have Maven execute at least the package phase, invoking the Java runtime with a larger maximum memory-allocation pool:

$ export MAVEN_OPTS=-Xmx256m; mvn package

Examples of setting proguard:liberate's optional parameters

The location of the jar containing the java runtime itself must be specified (using the libraryJars element) if, as on Mac OS X, it is not in the standard location (<java.home>/lib/rt.jar):

        <configuration>
          ...
          <libraryJars>
            <param>&lt;java.home&gt;/../Classes/classes.jar</param>
          </libraryJars>
        </configuration>

The dependencies being liberated from should be specified using the liberateFromDepsWhoseArtsStartWith and filter elements, although the default values should be sufficient if liberating from the scala-library and scala-swing jars:

        <configuration>
          ...
          <liberateFromDepsWhoseArtsStartWith>
            <param>some-large-lib-</param>
          </liberateFromDepsWhoseArtsStartWith>
          <filter>(!notInterestedIn/**, interestedIn/**)</filter>
        </configuration>

Any other dependencies which depend on those being liberated from should also be specified (using the alsoSupportDepsWhoseArtsStartWith element):

        <configuration>
          ...
          <alsoSupportDepsWhoseArtsStartWith>
            <param>lafros-gui-</param>
          </alsoSupportDepsWhoseArtsStartWith>
        </configuration>

Change log

  • 2010-May-11
    • Current version changed from 1.1-m2.1 to 1.2: addresses a bug which sometimes resulted in a NullPointerException being thrown if no alsoSupportDepsWhoseArtsStartWith element was supplied.
    • groupId changed from com.lafros.maven.plugins.proguard to just com.lafros.maven.plugins.