我正在尝试使用sbt-proguard获得更小的标量可执行 jar 文件。我添加了 project/plugin.sbt 这两行代码:
addSbtPlugin("com.eed3si9n" % "sbt-assembly" % "0.13.0")
addSbtPlugin("com.typesafe.sbt" % "sbt-proguard" % "0.2.2")
第一个是获取 uberjar 文件,我可以得到 uberjarsbt assembly
工作正常。
然后,我执行sbt proguard:proguard
以获取此错误消息。
[error] Error: Can't read [/Library/Java/JavaVirtualMachines/jdk1.8.0_25.jdk/Contents/Home/jre/lib/rt.jar] (Can't process class [apple/applescript/AppleScriptEngine.class] (Unsupported class version number [52.0] (maximum 51.0, Java 1.7)))
java.lang.RuntimeException: Proguard failed with exit code [1]
at scala.sys.package$.error(package.scala:27)
...
at java.lang.Thread.run(Thread.java:745)
[error] (proguard:proguard) Proguard failed with exit code [1]
根据这篇文章的提示:ProGuard 说 Unsupported class version number [52.0] (maximum 51.0, Java 1.7) with sbt-proguard ,我使用export JAVA_HOME=/usr/libexec/java_home -v '1.6*'
命令切换到 Java 1.7 和 Java 1.6以运行 proguard 以获得 slim-衬里的 jar 文件,但这不会运行。
Invalid or corrupt jarfile target/scala-2.11/proguard/myproject_2.11-1.0.jar
可能有什么问题?这些是添加到build.sbt
.
proguardSettings
ProguardKeys.options in Proguard ++= Seq("-dontnote", "-dontwarn", "-ignorewarnings")
ProguardKeys.options in Proguard += ProguardOptions.keepMain("core.HelloWorld")