工作Maven混淆示例 [英] Working maven obfuscate example

查看:84
本文介绍了工作Maven混淆示例的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我只想混淆简单的Maven Java应用程序.我使用maven-proguard-plugin.必须混淆所有的main/java类.我没有运气尝试不同的配置.最后是:

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>

结果-所有类都存在于目标jar中,但不会混淆,jad可以很好地对其进行反编译.怎么做对不对? 无法理解-只是混淆所有源代码是非常不常见的任务吗?所有其他插件都像开锁一样开箱即用.为什么我必须在此选项中键入一些奇怪的选项?我已经花了一天时间.我希望约定超过配置! :)

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! :)

推荐答案

让这样的事情变得很棒:).您可以做出自己想要的甚至不了解的事情.在阅读介绍后,我知道这是一个愚蠢的问题.保持参数非常重要.在此传递不得更改的公共方法.当然,插件不能自己理解您打算使用哪种方法.正确的配置:

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>

这篇关于工作Maven混淆示例的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆