开发者

sbt proguard plugin don't place my classes to jar

开发者 https://www.devze.com 2023-02-01 05:10 出处:网络
That is funny but my project configuration does everything to generate executable jar except adding my project classes to final jar:

That is funny but my project configuration does everything to generate executable jar except adding my project classes to final jar:

import sbt._

class ProjectDescriptor(info: ProjectInfo) extends DefaultProject(info) with ProguardProject{

  override def mainClass = Some("org.myproject.MyClass")

  override def proguardOptions = List(
    "-keepclasseswithmembers public class * { public static void main(java.lang.String[]); }",
    "-dontoptimize",
   开发者_如何学Python "-dontobfuscate",
    proguardKeepLimitedSerializability,
    proguardKeepAllScala,
    "-keep interface scala.ScalaObject"
  )
  val scalaLibraryPath = "<...>/project/boot/scala-2.8.0/lib"
  override def proguardInJars = super.proguardInJars +++ Path.fromFile(scalaLibraryPath)
}

How to fix it?


Instead of ProGuard, I use the OneJar plugin to create executable jars with sbt-onejar. It's a lot simpler since you don't have to mess with a bunch of options like ProGuard.


I am not sure what ProguardProject provides. But I think you can try

ProguardKeys.options in Proguard ++= Seq(
  ProguardOptions.keepMain("com.you.main.class")
)

This works for me.

0

精彩评论

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