使用Proguard对单个jar进行混淆依赖 [英] Obfuscate dependencies to single jar with Proguard

查看:209
本文介绍了使用Proguard对单个jar进行混淆依赖的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有模块化的maven应用程序,module1取决于module2和module2取决于module3等。在module1中,我有这样的东西:

 <型材> 
< id> obfuscate< / id>
< build>
< plugins>
< plugin>
< groupId> com.pyx4me< / groupId>
< artifactId> proguard-maven-plugin< / artifactId>
<执行>
< execution>
< phase> package< / phase>
< goals>
< goal> proguard< / goal>
< / goals>
< / execution>
< / executions>
< configuration>
< options>
< option> -allowaccessmodification< / option>
< option> --keep public class com.test.Main {*; }< /选项>
< / options>
< libs>
< lib> $ {java.home} /lib/rt.jar</lib>
< / libs>
< / configuration>
<依赖关系>
<依赖关系>
< groupId> net.sf.proguard< / groupId>
< artifactId> proguard< / artifactId>
< version> $ {proguard.version}< / version>
< / dependency>
< / dependencies>
< / plugin>
< / plugins>
< / build>



这将创建成功模糊的module1 。我想用所有模糊依赖关系创建单个jar(模糊化模块1和模块2等)。是否可能?

解决方案

Maven Shade Plugin



将这些工件打包在一个uber-jar中,包括它的依赖关系和一些依赖关系(即重命名)包的功能。



请查看这里


I have modular maven application and "module1" depends on "module2" and "module2" depends on "module3" etc.. In module1 I have something like this:

<profile>
<id>obfuscate</id>
<build>
    <plugins>
        <plugin>
            <groupId>com.pyx4me</groupId>
            <artifactId>proguard-maven-plugin</artifactId>
            <executions>
                <execution>
                    <phase>package</phase>
                    <goals>
                        <goal>proguard</goal>
                    </goals>
                </execution>
            </executions>
            <configuration>
                <options>
                    <option>-allowaccessmodification</option>
                    <option>-keep public class com.test.Main { *; }</option>
                </options>
                <libs>
                    <lib>${java.home}/lib/rt.jar</lib>
                </libs>
            </configuration>
            <dependencies>
                <dependency>
                    <groupId>net.sf.proguard</groupId>
                    <artifactId>proguard</artifactId>
                    <version>${proguard.version}</version>
                </dependency>
            </dependencies>
        </plugin>
    </plugins>
</build>

This creates successfully obfuscated "module1". I want to create single jar with all obfuscated dependencies (obfuscated module1 and module2 etc.). Is it possible?

解决方案

Maven Shade Plugin

This plugin provides the capability to package the artifact in an uber-jar, including its dependencies and to shade - i.e. rename - the packages of some of the dependencies.

Check it out here.

这篇关于使用Proguard对单个jar进行混淆依赖的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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