我有一个这样的目录结构:
CSV_generator
src
main
scala
CSVGenerator.scala
project
plugins.sbt我的scala对象的内容如下:
package tools.csv_generator
object CSV_Generator{
import java.nio.file.{Paths, Files}
import java.io.File
import org.rogach.scallop._
def main(args: Array[String]){
val opts = new ScallopConf(args) {
banner("""This is the program CSV Generator""")
val file_path = opt[String]("file_path",
required = true,
descr = "File Path")
val dome_string = opt[String]("dome_string",
required = true,
descr = "Dome String")
}我的csv_generator/project/plugins.sbt:
addSbtPlugin("com.typesafe.sbt" % "sbt-proguard" % "0.2.2")我的csv_generator/build.sbt是:
proguardSettings
ProguardKeys.options in Proguard ++= Seq("-dontnote", "-dontwarn", "-ignorewarnings"
, "-keepclasseswithmembers class scala.CSV_Generator")
ProguardKeys.options in Proguard += ProguardOptions.keepMain("src.main.scala.CSV_Generator")在我的sbt中,当我运行proguard:proguard试图将我的所有代码打包到一个可运行的独立jar文件中时,我得到的结果是:
[error] Error: The output jar is empty. Did you specify the proper '-keep' options?
[trace] Stack trace suppressed: run last proguard:proguard for the full output.
[error] (proguard:proguard) Proguard failed with exit code [1]
[error] Total time: 14 s, completed Jan 31, 2014 12:18:38 AM对于像我这样的小应用程序来说,proguard的例子很少。有人能帮帮忙吗?
发布于 2014-02-02 18:01:01
您还需要保留main方法作为入口点:
-keep class scala.CSV_Generator {
public static void main(java.lang.String[]);
}ProGuard通常会对此发出警告;最好不要关闭警告和注释。
请参见ProGuard文档>示例> A typical application
发布于 2014-02-06 11:06:18
另一种不太强大的解决方案更接近clojure的uberjar,我发现它非常适合我,那就是sbt " One -jar“。可在以下位置找到:
https://github.com/retronym/sbt-onejar
只需几行配置就可以工作,一切都可以很好地打包。这更接近我所需要的。
https://stackoverflow.com/questions/21461745
复制相似问题