如何在我的JavaFX的IntelliJ工件中集成Proguard混淆? [英] How to integrate Proguard obfuscation in my JavaFX's IntelliJ artifact?

查看:1316
本文介绍了如何在我的JavaFX的IntelliJ工件中集成Proguard混淆?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用IntelliJ IDEA作为IDE开发JavaFX应用程序。

I'm developing a JavaFX application using IntelliJ IDEA as the IDE.

到目前为止,一切运行顺利,我配置了所有外部库和我的JavaFX工件正确创建。

So far, everything runs smoothly, I have all my external libs configured and my JavaFX artifact being correctly created.

现在我想在创建工件时集成模糊处理(使用Proguard)。

Now I would like to integrate obfuscation (using Proguard) when the artifact is created.

IntelliJ在工件属性中有一个'预处理'和'后处理'选项,我可以在其中定义要运行的Ant任务。

IntelliJ have a 'Pre-processing' and 'Post-processing' option in artifact's properties where I can define an Ant task to be runned.

但我不知道如何创建该任务并告诉编译器我的混淆选项。

But I have no idea how to create that task and tell the compiler my obfuscation options.

非常感谢您提前获取任何线索,

Thank you very much in advance for any clues,

祝你好运

推荐答案

有三种基本方法:


  1. 创建一个正常的proguard.cfg文件,并从ant引用它

  2. 使用XML表示法将您的proguard设置直接放在ant中

  3. 将你的proguard设置直接放在我们的内部proguard.cfg格式

以下是使用Proguard和Ant的第三种方法的基本示例:
http://www.reviewmylife.co.uk/blog / 2007/10/20 / proguard-eclipse-ant-buildxml /

Here's a basic example of using Proguard with Ant with the 3rd approach: http://www.reviewmylife.co.uk/blog/2007/10/20/proguard-eclipse-ant-buildxml/

关于Proguard的重要事项是,你想要混淆的一切都必须在JAR文件中,你需要明确告诉它不要混淆某些东西(比如你的程序入口点,你通过反射访问的东西等)。

The important thing to remember about Proguard is that everything you want to obfuscate has to be inside a JAR file, and you'll need to explicitly tell it not to obfuscate certain things (like your program entry point, things you access via reflection, etc).

JavaFX创建一个文件,用作要防止混淆的入口点:

JavaFX creates a file used as an entry point you want to prevent obfuscating:

-keepclasseswithmembers public class com.javafx.main.Main {
    public *; public static *;
}

确保包含Java / JavaFX库

Make sure to include Java/JavaFX libs

-libraryjars "${java.home}/lib/rt.jar"
-libraryjars "${java.home}/lib/ant-javafx.jar"
-libraryjars "${java.home}/lib/jfxrt.jar"

如果您使用的是FXML文件,则需要确保将FXML文件重命名为与各自的控制器文件类似:

If you're using FXML files, you'll want to make sure your FXML files are renamed similarly to their respective controller file:

-adaptresourcefilecontents **.fxml

任何使用@FXML注释的内容都是通过反射访问的,所以不要混淆它们:

Anything annotated with @FXML is accessed through reflection, so don't obfuscate them:

-keepclassmembernames class * {
        @javafx.fxml.FXML *;
    }

Proguard网站有很多信息,但可能很难理解。

The Proguard website has a lot of information, but it can be difficult to grok.

老实说,网上有很多例子可以告诉你如何做到这一点。只需google javafx proguard,您可能会找到一些很好的完整示例。

Honestly, there are plenty of examples on the web that show you how to do this. Just google javafx proguard, and you'll probably find some good complete examples.

编辑:就IntelliJ如何将信息传递给Ant而言......我不知道。它可能会传递一些变量,就像正常的Ant一样。如果你在网上找不到它,我肯定JetBrains网站会在他们的网站上有相关信息。

as far as how IntelliJ passes information to Ant.. I don't know. There are probably some variables it passes in that you reference like a normal Ant propertly. I'm sure JetBrains website has info on that on their website if you can't find it on the net.

如果是我,我只是创建一个ant脚本来编译我的应用程序而不进行混淆,然后在你得到平方后添加proguard。

If it was me, I'd just create an ant script to compile my application without obfuscation, then add in proguard once you've got that squared away.

这篇关于如何在我的JavaFX的IntelliJ工件中集成Proguard混淆?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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