我正在使用SBT(在IntelliJ IDEA中)构建一个简单的Scala项目。
我想知道构建“Uber JAR”文件(也称为Fat JAR、Super JAR)的最简单的方法是什么。
我目前正在使用SBT,但当我将我的JAR文件提交到Apache Spark时,会出现以下错误:
Exception in thread "main" java.lang.SecurityException: Invalid signature file digest for Manifest main attributes
或者在编译时出现以下错误:
java.lang.RuntimeException: deduplicate: different file contents found in the following:
PATH\DEPENDENCY.jar:META-INF/DEPENDENCIES
PATH\DEPENDENCY.jar:META-INF/MANIFEST.MF
看起来是因为我的某些依赖项包括需要在最终的Uber JAR文件中删除的签名文件(META-INF),如此处所述。
我尝试使用sbt-assembly插件来解决这个问题:
/project/assembly.sbt
addSbtPlugin("com.eed3si9n" % "sbt-assembly" % "0.12.0")
/project/plugins.sbt
logLevel := Level.Warn
/build.sbt
lazy val commonSettings = Seq(
name := "Spark-Test"
version := "1.0"
scalaVersion := "2.11.4"
)
lazy val app = (project in file("app")).
settings(commonSettings: _*).
settings(
libraryDependencies ++= Seq(
"org.apache.spark" %% "spark-core" % "1.2.0",
"org.apache.spark" %% "spark-streaming" % "1.2.0",
"org.apache.spark" % "spark-streaming-twitter_2.10" % "1.2.0"
)
)
在 IntelliJ IDEA 中点击 "Build Artifact..." 后,我得到了一个 JAR 文件。但我最终遇到了相同的错误...
我对 SBT 不是很熟悉,也没有太多 IntelliJ IDE 的经验。
谢谢。
META-INF
文件 - 这篇博客或许可以帮到你:https://janschulte.wordpress.com/2014/03/20/removing-meta-inf-directory-from-sbt-assembly/ - Sean Vieira