Working maven obfuscate example

后端 未结 1 1681
庸人自扰
庸人自扰 2021-02-03 13:40

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:

相关标签:
1条回答
  • 2021-02-03 14:26

    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>
    
    0 讨论(0)
提交回复
热议问题