Question

I just want to obfuscate simple maven java app. I use maven-proguard-plugin. All classes main/java must be obfuscated. I try different configs with no luck. The last is:

    <build>
    <plugins>
        <plugin>
            <groupId>com.github.wvengen</groupId>
            <artifactId>proguard-maven-plugin</artifactId>
            <version>2.0.6</version>
            <dependencies>
                <dependency>
                    <groupId>net.sf.proguard</groupId>
                    <artifactId>proguard-base</artifactId>
                    <version>4.10</version>
                    <scope>runtime</scope>
                </dependency>
            </dependencies>
            <executions>
               <execution>
                   <phase>package</phase>
                   <goals><goal>proguard</goal></goals>
               </execution>
            </executions>
            <configuration>
                <proguardVersion>4.10</proguardVersion>
                <options>
                    <option>-keep class *{*;}</option>
                </options>
                <libs>
                    <lib>${java.home}/lib/rt.jar</lib>
                </libs>
            </configuration>
        </plugin>
    </plugins>
</build>

result - all classes exist in target jar, but not obfuscated, jad decompiles it well. How to do obfuscate right? Can't understand - is just obfuscate all source are very uncommon task? All other plugins works out of the box like a charm. Why i must type some strange options in this one? I spent a day already. I want convention over configuration! :)

Was it helpful?

Solution

Maven such a great thing :). You can make what you want and even not understand, what you want. After i read the introduction, i understand that it's a stupid question. Keep parameter is very important. Here pass in the public methods which must not changed. Of course plugin can't undestand by itself what methods you plan to use. Correct config:

<build>
    <plugins>
        <plugin>
            <groupId>com.github.wvengen</groupId>
            <artifactId>proguard-maven-plugin</artifactId>
            <version>2.0.6</version>
            <dependencies>
                <dependency>
                    <groupId>net.sf.proguard</groupId>
                    <artifactId>proguard-base</artifactId>
                    <version>4.10</version>
                </dependency>
            </dependencies>
            <executions>
               <execution>
                   <phase>package</phase>
                   <goals><goal>proguard</goal></goals>
               </execution>
            </executions>
            <configuration>
                <proguardVersion>4.10</proguardVersion>
                <options>
                    <option>-keep public class myapp.Main{public static void main(java.lang.String[]);}</option>
                </options>
                <libs>
                    <lib>${java.home}/lib/rt.jar</lib>
                    <lib>${java.home}/lib/jce.jar</lib>
                </libs>
            </configuration>
        </plugin>
    </plugins>
</build>
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top