开发者

Adding scala-compiler.jar as a runtime dependency

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 ja开发者_运维技巧r. 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


This works, but is sensitive to the location from which sbt is called:

//proguard                                                                    
override def proguardOptions = List(
  "-dontshrink -dontoptimize -dontobfuscate -dontpreverify -dontnote " +
  "-ignorewarnings",
  proguardKeepAllScala
)

val cur =  new File(".").getAbsolutePath
override def proguardInJars =
  Path.fromFile(scalaLibraryJar) +++
  Path.fromFile(
    new File(cur, "project/boot/scala-" + crossScalaVersionString +
             "/lib/scala-compiler.jar")) +++
  super.proguardInJars

I could not use FileUtilities.scalaCompilerJar because that gets the 2.7.7 jar that sbt uses, not the cross scala version compiler.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜