添加 scala-compiler.jar 作为运行时依赖项
我正在使用 sbt 及其 Proguard 插件为我的程序创建可执行 jar。但是,我的程序在运行时依赖于 scala-compiler.jar 来进行编译。我似乎无法将 scala-compiler.jar 放入我的最终 jar 中。 此页面有一些非常相似的信息,但我无法获取它从头到尾工作。有什么建议吗?
编辑:这是我得到的最接近的:
override def proguardOptions = List(
"-dontshrink -dontoptimize -dontobfuscate -dontpreverify -dontnote " +
"-ignorewarnings",
proguardKeepAllScala
)
override def proguardInJars =
Path.fromFile(scalaLibraryJar) +++
Path.fromFile(FileUtilities.scalaCompilerJar) +++
super.proguardInJars
其中包括 proguard min jar 中的编译器 jar,但运行它我仍然得到:
Exception: java.lang.NoClassDefFoundError: scala/tools/nsc/settings/Scala Settings
I'm using sbt and its Proguard plugin to create an executable jar for my program. However, my program relies on scala-compiler.jar
at runtime to do compilations. I can't seem to get scala-compiler.jar
into my final jar. This page has some very similar information but I can't get it to work beginning to end. Any suggestions?
EDIT: This is the closest I have gotten:
override def proguardOptions = List(
"-dontshrink -dontoptimize -dontobfuscate -dontpreverify -dontnote " +
"-ignorewarnings",
proguardKeepAllScala
)
override def proguardInJars =
Path.fromFile(scalaLibraryJar) +++
Path.fromFile(FileUtilities.scalaCompilerJar) +++
super.proguardInJars
That includes the compiler jar in the proguard min jar, but running it I still get:
Exception: java.lang.NoClassDefFoundError: scala/tools/nsc/settings/Scala Settings
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这有效,但对调用 sbt 的位置敏感:
我无法使用 FileUtilities.scalaCompiler Jar 因为它获取 sbt 使用的 2.7.7 jar,而不是跨 scala 版本编译器。
This works, but is sensitive to the location from which
sbt
is called:I could not use
FileUtilities.scalaCompiler
Jar because that gets the 2.7.7 jar that sbt uses, not the cross scala version compiler.