我一直在试图让Proguard
与Spring-boot
工作为obfuscation
,但一直没能得到Spring-boot
与maven
建成后运行。我搜查了一下,发现一些人在谈论同一个问题,但我还没有看到它解决了。
我有2个应用程序。
- A2需要A1
- A1
我只真正需要的obfuscation
建设成A2,但我非常希望将其建成两者。
我正在创建一个executable
Spring-boot
jar来运行A1和A3。
我能得到maven
打包和创建executable
jar
但是当我运行它,我得到以下称compressed and nested jar files must be stored without compression
堆栈跟踪。
问题
我怎样才能得到proguard
建立我的应用程序而不压缩嵌套罐子?
谢谢
堆栈跟踪
Exception in thread "main" java.lang.IllegalStateException: Unable to open nested entry 'BOOT-INF/lib/commons-lang3-3.4.jar'. It has been compressed and nested jar files must be stored without compression. Please check the mechanism used to create your executable jar file
at org.springframework.boot.loader.c.k.e(JarFile.java:285)
at org.springframework.boot.loader.c.k.c(JarFile.java:260)
at org.springframework.boot.loader.c.k.a(JarFile.java:248)
at org.springframework.boot.loader.c.k.a(JarFile.java:237)
at org.springframework.boot.loader.a.c.a(JarFileArchive.java:103)
at org.springframework.boot.loader.a.c.a(JarFileArchive.java:87)
at org.springframework.boot.loader.a.c(ExecutableArchiveLauncher.java:72)
at org.springframework.boot.loader.c.a(Launcher.java:49)
at org.springframework.boot.loader.JarLauncher.main(JarLauncher.java:58)
为POM插件细节
<plugin>
<groupId>com.github.wvengen</groupId>
<artifactId>proguard-maven-plugin</artifactId>
<version>2.0.13</version>
<executions>
<execution>
<id>proguard</id>
<phase>package</phase>
<goals>
<goal>proguard</goal>
</goals>
</execution>
</executions>
<configuration>
<!-- File with proguard configuration -->
<proguardInclude>${basedir}/proguard.conf</proguardInclude>
<obfuscate>true</obfuscate>
<libs>
<lib>${java.home}/lib/rt.jar</lib>
<lib>${java.home}/lib/jce.jar</lib>
</libs>
<options>
<option>-optimizations !class/marking/final</option>
<option>-adaptresourcefilecontents **.properties,META-INF/MANIFEST.MF,META-INF/spring.*</option>
<option>-keepattributes Exceptions,InnerClasses,Signature,Deprecated,SourceFile,LineNumberTable,*Annotation*,EnclosingMethod</option>
<option>-keepclasseswithmembers public class * { public static void main(java.lang.String[]);}</option>
</options>
</configuration>
<dependencies>
<dependency>
<groupId>net.sf.proguard</groupId>
<artifactId>proguard-base</artifactId>
<version>5.2.1</version>
<scope>runtime</scope>
</dependency>
</dependencies>
</plugin>
Proguard.conf
# Don't obfuscate or remove your entry point
-keep public class com.something.InitialRunner{public static void main(java.lang.String[]);}
-ignorewarnings
-dontoptimize
-dontshrink
# Uncomment if you want to have more meaningful backtraces
# Useful for obfuscation debugging
# You absolutely must keep this commented out for production
#-keepattributes SourceFile,LineNumberTable
在Maven中,你是否将所有依赖关系放入一个单独的jar中执行?这可能是问题所在。我一直不得不将Spring库保存在可执行文件jar之外,以便它们正常工作。 – JRSofty
@JRSofty是的,我试图让它构建一切,包括Spring和我所有的库。你如何设置你的构建,然后排除这些库并在运行时使用它们?你是在没有弹簧库的情况下构建混淆瓶子,然后重建这个罐子和弹簧来制作一个可执行文件?谢谢 – ALM
这可能是maven正在执行压缩。您可能需要检查文档。一个检查是编译没有proguard,看看jar是否运行或抛出相同的异常。 – JRSofty