wvengen / proguard-maven-plugin

ProGuard Maven plugin that supports modularised ProGuard packages
http://wvengen.github.io/proguard-maven-plugin/
Apache License 2.0
610 stars 152 forks source link

Wrong resource file encoding when using proguard obfuscation option -adaptresourcefilecontents #371

Open rolandas-karosas opened 1 month ago

rolandas-karosas commented 1 month ago

after obfuscation resource file(s) become corrupted (UTF-8 encoding is lost)

OS name: "windows 11" Java 8 Maven 3.9.7

plugin configuration:

proguard.conf

proguard.conf: -dontshrink -dontoptimize -adaptresourcefilecontents META-INF/**.tld

All my resource files are correct with UTF-8 encoding.

Need to pass JVM argument -Dfile.encoding=UTF-8 to the forked java process. (same as passing maxMemory)

I checked directly executing proguard.jar. With argument -Dfile.encoding=UTF-8 resource files are good. Without argument -Dfile.encoding=UTF-8 I also get corrupted resource files.

P.S. other maven plugins (surefire plugin, failsafe plugin) have argLine argument for passing JVM options to the forked java process

lasselindqvist commented 1 month ago

Arguments are passed here https://github.com/wvengen/proguard-maven-plugin/blob/master/src/main/java/com/github/wvengen/maven/proguard/ProGuardMojo.java#L1037 It should be relatively easy to pass file.encoding on

rolandas-karosas commented 1 month ago

Arguments are passed here https://github.com/wvengen/proguard-maven-plugin/blob/master/src/main/java/com/github/wvengen/maven/proguard/ProGuardMojo.java#L1037 It should be relatively easy to pass file.encoding on

These are main class arguments? Not the jvm args for java fork. I get proguard.ParseException: Unknown option https://github.com/Guardsquare/proguard/blob/master/base/src/main/java/proguard/ConfigurationParser.java#L169

lasselindqvist commented 1 month ago

Yes, you cannot pass it via that directly, but using https://ant.apache.org/manual/api/org/apache/tools/ant/taskdefs/Java.html#createJvmarg()

But it should be done in similar place.