用于多个maven模块项目的proguard [英] proguard for multiple maven module project
问题描述
在多模块maven项目中,我有一个插件引用了proguard。
我的项目的功能已经过全面测试,可以运行......直到我添加了proguard。
我的项目结构
父-Pom
-module-a-pom
-module-b-pom
tester-pom
- 模块-b对模块-a具有依赖性。
- 模块-a和模块-b都是安装到我的本地maven仓库。
- 测试人员对模块-a和模块-b都有依赖性。
- 我的proguard.conf文件位于文件系统上的parent-pom pom.xml文件。
- 我在module-a和module-b pom.xml文件中配置了proguard。
我的proguard配置看起来像这样:
<插件>
< groupId> com.github.wvengen< / groupId>
< artifactId> proguard-maven-plugin< / artifactId>
< version> 2.0.8< / version>
<执行次数>
<执行>
< id> process-classes-with-proguard< / id>
<阶段>程序类< /阶段>
<目标>
< goal> proguard< / goal>
< /目标>
<配置>
< injar>课程< / injar>
< proguardVersion> 5.1< / proguardVersion>
< proguardInclude> $ {project.basedir} /../ proguard.conf< / proguardInclude>
< libs>
< lib> $ {java.bootstrap.classes}< / lib>
< lib> $ {java.secure.socket.extension.classes}< / lib>
< lib> $ {java.cryptographic.extension.classes}< / lib>
< / libs>
< obfuscate> true< / obfuscate>
< / configuration>
< /执行>
< /执行次数>
<依赖关系>
< dependency>
< groupId> net.sf.proguard< / groupId>
< artifactId> proguard-base< / artifactId>
< version> 5.1< / version>
< scope>运行时< / scope>
< /依赖关系>
< /依赖关系>
< / plugin>
我的项目使用GSON从外部对一些传入的JSON进行反序列化
作为构建的一部分执行proguard会导致GSON代码抛出NullPointerExceptions
受到proguard影响的代码是:
Gson gson = new Gson();
类型collectionType = new TypeToken< ArrayList< MyType>>(){}。getType();
ArrayList< MyType> myTypes = gson.fromJson(json,collectionType);
如果proguard在我的pom文件中被注释掉(所以它不会执行),这个代码我的项目的其余部分)就像一个魅力。
如何配置proguard来混淆我的代码但不破坏功能?这是可能的多模块项目?
是否任何人知道如何配置多模块maven项目的proguard?
注意:我已经尝试了此,它似乎对结果没有任何影响。
我最终得到了这个工作:
- 使用Windows Proguard应用程序并通过向导选择相对基本的设置
- 导出配置
- 关闭我的眼睛并按下开始按钮。
..它工作正常!
I have a plugin reference to proguard in a multi-module maven project.
The functionality of my project is fully tested and works...until I add proguard.
Structure of my Project
parent-pom
-module-a-pom
-module-b-pom
tester-pom
- module-b has a dependency on module-a.
- module-a and module-b are both installed to my local maven repository.
- tester has dependencies on both module-a and module-b.
- My proguard.conf file is next to the parent-pom pom.xml file on the file system.
- I configure proguard in both module-a and module-b pom.xml files.
My proguard config looks like so:
<plugin>
<groupId>com.github.wvengen</groupId>
<artifactId>proguard-maven-plugin</artifactId>
<version>2.0.8</version>
<executions>
<execution>
<id>process-classes-with-proguard</id>
<phase>process-classes</phase>
<goals>
<goal>proguard</goal>
</goals>
<configuration>
<injar>classes</injar>
<proguardVersion>5.1</proguardVersion>
<proguardInclude>${project.basedir}/../proguard.conf </proguardInclude>
<libs>
<lib>${java.bootstrap.classes}</lib>
<lib>${java.secure.socket.extension.classes}</lib>
<lib>${java.cryptographic.extension.classes}</lib>
</libs>
<obfuscate>true</obfuscate>
</configuration>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>net.sf.proguard</groupId>
<artifactId>proguard-base</artifactId>
<version>5.1</version>
<scope>runtime</scope>
</dependency>
</dependencies>
</plugin>
I have the added complexity that my project is using GSON to deserialise some incoming JSON from an external component I have no control over.
Executing proguard as part of the build causes the GSON code to throw NullPointerExceptions
The code that is effected by proguard is:
Gson gson = new Gson();
Type collectionType = new TypeToken<ArrayList<MyType>>(){}.getType();
ArrayList<MyType> myTypes = gson.fromJson(json, collectionType);
If proguard is commented out in my pom files (so it doesn't execute), this code (and the rest of my project) works like a charm.
How can I configure proguard to obsfuscate my code but not break the functionality? Is this possible with a multimodule project?
Does anyone out there know how to configure proguard for a multimodule maven project?
NB: I have already tried this and it seemed to make no difference to the outcome.
I eventually got this working by:
- Using the Windows Proguard application and selecting relatively basic settings through the wizard
- Exporting the configuration
- Closing my eyes and pressing the go button.
..and it worked!
这篇关于用于多个maven模块项目的proguard的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!