rzhomx
rzhomx

Reputation: 95

Proguard with Maven

I am trying to use Proguard to shrink the jar size.

I configured Proguard in Maven pom.xml. It failed to find all the embedded dependency jars. It can read and parse out all dependency jars which is referenced in the current module, but for dependencies which are embedded in the other modules, it failed to find it.

For example, My current module is moduleA and it depends another module moduleB. And module B has a dependency moduleC. It can find all classes which are directly inside moduleB, but it failed to parse out all classes which are inside moduleC. My configuration for proguard is as following:

<plugin>
            <!--groupId>com.pyx4me</groupId-->
            <groupId>com.github.wvengen</groupId>
            <artifactId>proguard-maven-plugin</artifactId>
            <executions>
              <execution>
                <id>proguard</id>
                <phase>package</phase>
                <goals>
                  <goal>proguard</goal>
                </goals>
              </execution>
            </executions>
            <configuration>
              <injar>MyInput-${project.version}.jar</injar>
              <outjar>MyInput-Processed-${project.version}.jar</outjar>
              <options>
                <option>-keep public class * { *; }</option>
                <option>-ignorewarnings</option>
              </options>
              <libs>
                <!--lib>${java.bootstrap.classes}</lib>
                <lib>${java.cryptographic.extension.classes}</lib>
                <lib>${java.secure.socket.extension.classes}</lib-->
              </libs>
            </configuration>
            <dependencies>
              <dependency>
                <groupId>net.sf.proguard</groupId>
                <artifactId>proguard-base</artifactId>
                <version>4.10</version>
                <scope>runtime</scope>
              </dependency>
            </dependencies>
        </plugin>

Upvotes: 1

Views: 4744

Answers (2)

Morty
Morty

Reputation: 3219

There is a newer version of that plugin at: https://github.com/wvengen/proguard-maven-plugin

Upvotes: 0

witold
witold

Reputation: 11

I had similar problem, however it could find the references mentioned in the plugin's configuration dependencies section.

However, if I tried to use the proguard-base-4.10 the proguard-maven-plugin (with com.pyx4me groupId) still used the proguard-4.3.jar (you can see it in the maven output in the console); looks like the plugin is only working with a "proguard" artifact, not a "proguard-base".

So I configured the dependencies section to look like:

<dependency>
  <groupId>net.sf.proguard</groupId>
  <artifactId>proguard</artifactId>
  <version>4.10</version>
  <scope>runtime</scope>
</dependency>

but this one is not available in the central maven repo (the latest version is 4.4).

What I did was to download the proguard-4.10 manually from proguard download section and install the proguard.jar in the local maven repository under the version 4.10 - and now everything works fine.

Upvotes: 1

Related Questions