我正在使用Proguard插件来混淆我使用JavaFX的项目。问题是,.fxml文件中的id没有混淆,因此无法连接到控制器。已经在谷歌上试过了,没有成功…什么好主意吗?Proguard配置:
<plugin>
<groupId>com.github.wvengen</groupId>
<artifactId>proguard-maven-plugin</artifactId>
<version>2.0.11</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>proguard</goal>
</goals>
</execution>
</executions>
<configuration>
<obfuscate>true</obfuscate>
<injar>${project.build.finalName}.jar</injar>
<outjar>${project.build.finalName}-final.jar</outjar>
<includeDependency>true</includeDependency>
<options>
<option>-keep public class com.skriptide.main.Main { public static void
main(java.lang.String[]); }
</option>
<option>-keepattributes Signature,*Annotation*,Exceptions</option>
<option>-dontusemixedcaseclassnames</option>
<option>-dontskipnonpubliclibraryclasses</option>
<option>-verbose</option>
</options>
<libs>
<lib>${java.home}/lib/rt.jar</lib>
<lib>${java.home}/lib/jce.jar</lib>
<lib>${java.home}/lib/ext/jfxrt.jar</lib>
<lib>${java.home}/lib/jfxswt.jar</lib>
</libs>
<assembly>
<inclusions>
<inclusion>
<groupId>org.ini4j</groupId>
<artifactId>ini4j</artifactId>
<library>true</library>
</inclusion>
<inclusion>
<groupId>org.fxmisc.richtext</groupId>
<artifactId>richtextfx</artifactId>
<library>true</library>
</inclusion>
<inclusion>
<groupId>org.json</groupId>
<artifactId>json</artifactId>
<library>true</library>
</inclusion>
<inclusion>
<groupId>org.yaml</groupId>
<artifactId>snakeyaml</artifactId>
<library>true</library>
</inclusion>
<inclusion>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<library>true</library>
</inclusion>
</inclusions>
</assembly>
<archive>
<manifest>
<mainClass>com.skriptide.main.Main</mainClass>
</manifest>
</archive>
</configuration>
<dependencies>
<dependency>
<groupId>net.sf.proguard</groupId>
<artifactId>proguard-base</artifactId>
<version>5.2.1</version>
<scope>runtime</scope>
</dependency>
</dependencies>
</plugin>
谢谢
您必须指示ProGuard也重命名。fxml文件中混淆的类名。假设它们已经包含在原始jar文件中,您可以尝试将以下选项添加到proguard配置中:
<options>
...
<option>-adaptresourcefilecontents **.fxml</option>
...
</options>