Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

proguard-maven-plugin java 8

I am trying to use Proguard to obfuscate my Java 8 App.

Proguard supports Java 8 since version 5.0

For some reason the program-maven-plugin ignores my configuration to use Proguard version 5.1 and uses 4.3, incompatible with Java 8.

My configuration is

<plugin>
        <groupId>com.pyx4me</groupId>
        <artifactId>proguard-maven-plugin</artifactId>
    <version>2.0.4</version>
        <executions>
            <execution>
                <phase>package</phase>
                <goals>
                    <goal>proguard</goal>
                </goals>
            </execution>
        </executions>
        <configuration>
    <proguardVersion>5.1</proguardVersion>
    <obfuscate>true</obfuscate>
            <options>
                <option>-allowaccessmodification</option>
                <option>-keep class mypackage.Testt</option>
            </options>
            <libs>
                <lib>${java.home}/lib/rt.jar</lib>
        <lib>${java.home}/lib/javafx-mx.jar</lib>
            </libs>
        </configuration>
        <dependencies>
          <dependency>
            <groupId>net.sf.proguard</groupId>
            <artifactId>proguard-base</artifactId>
            <version>5.1</version>
            <scope>runtime</scope>
          </dependency>
        </dependencies>
  </plugin>

Any clue?

Tks,

like image 319
Chocksmith Avatar asked Nov 24 '14 20:11

Chocksmith


1 Answers

Answering my own question... It happens that Proguard version 5.1 is not yet available on Maven repositories. It is necessary to manually download it and run:

mvn install:install-file -Dfile=./proguard.jar -DgroupId=net.sf.proguard -DartifactId=proguard -Dversion=5.1 -Dpackaging=jar

In addition, the correct Proguard configuration is:

<dependency>
            <groupId>net.sf.proguard</groupId>
            <artifactId>proguard</artifactId>
            <version>5.1</version>
</dependency>
like image 191
Chocksmith Avatar answered Nov 06 '22 20:11

Chocksmith