SBT 构建文件无法识别 "assembly"
SBT build file not recognizing "assembly"
我有一个 build.sbt 文件可以在 sbt 13.7 中正常工作。但是在 13.8 中它给了我一个 "type error in expression" 错误。它在这一行的开头抛出错误:
mergeStrategy in assembly <<= (mergeStrategy in assembly) { (old) =>
{ ...
如果我完全擦除 mergeStrategy 块,它会在这一行的开头给出相同的 "type error in expression":
jarName in assembly := "theBigServer.jar"
所以我假设 "assembly" 有问题。这应该在 13.8 中以不同方式处理吗?
这是完整的 build.sbt 文件:
organization := "com.myco"
version := "0.1"
scalaVersion := "2.11.6"
scalacOptions := Seq("-unchecked", "-deprecation", "-encoding", "utf8")
resolvers ++= Seq(
"spray repo" at "http://repo.spray.io/",
"Scalaz Bintray Repo" at "http://dl.bintray.com/scalaz/releases" // for scalaz-stream
)
libraryDependencies ++= {
val akkaV = "2.3.9"
val sprayV = "1.3.2"
Seq(
"io.spray" %% "spray-can" % sprayV,
"io.spray" %% "spray-routing" % sprayV,
"io.spray" %% "spray-testkit" % sprayV,
"io.argonaut" %% "argonaut" % "6.0.4",
"com.typesafe.akka" %% "akka-actor" % akkaV,
"com.typesafe.akka" %% "akka-testkit" % akkaV,
"com.github.nscala-time" %% "nscala-time" % "1.8.0",
"commons-codec" % "commons-codec" % "1.10",
"com.amazonaws" % "aws-java-sdk" % "1.9.25"
)
}
seq(Revolver.settings: _*)
// put this in to eliminate deduplicate errors in sbt-assembly when making fat JAR
mergeStrategy in assembly <<= (mergeStrategy in assembly) { (old) =>
{
case PathList(ps @ _*) if ps.last endsWith "ArgumentsProcessor.class" => MergeStrategy.first
case PathList(ps @ _*) if ps.last endsWith "MatchersBinder.class" => MergeStrategy.first
case "application.conf" => MergeStrategy.concat
case "unwanted.txt" => MergeStrategy.discard
case x => old(x)
}
}
jarName in assembly := "theBigServer.jar"
mainClass in assembly := Some("servletRunner.Boot")
好的,已修复 - 问题似乎出在我安装 sbt 的方式上。我按照 scala-sbt.org 的 manual installation instructions (which actually just specify unix, and I'd assumed held for linux too.) That caused the problems I was seeing above. I then uninstalled, and reinstalled via apt-get
using their Debian instructions 将它安装到 linux mint 17 上,现在 sbt 工作正常。我没有再花时间尝试修复我的手动安装。也许有办法让它发挥作用。不知道。
我有一个 build.sbt 文件可以在 sbt 13.7 中正常工作。但是在 13.8 中它给了我一个 "type error in expression" 错误。它在这一行的开头抛出错误:
mergeStrategy in assembly <<= (mergeStrategy in assembly) { (old) =>
{ ...
如果我完全擦除 mergeStrategy 块,它会在这一行的开头给出相同的 "type error in expression":
jarName in assembly := "theBigServer.jar"
所以我假设 "assembly" 有问题。这应该在 13.8 中以不同方式处理吗?
这是完整的 build.sbt 文件:
organization := "com.myco"
version := "0.1"
scalaVersion := "2.11.6"
scalacOptions := Seq("-unchecked", "-deprecation", "-encoding", "utf8")
resolvers ++= Seq(
"spray repo" at "http://repo.spray.io/",
"Scalaz Bintray Repo" at "http://dl.bintray.com/scalaz/releases" // for scalaz-stream
)
libraryDependencies ++= {
val akkaV = "2.3.9"
val sprayV = "1.3.2"
Seq(
"io.spray" %% "spray-can" % sprayV,
"io.spray" %% "spray-routing" % sprayV,
"io.spray" %% "spray-testkit" % sprayV,
"io.argonaut" %% "argonaut" % "6.0.4",
"com.typesafe.akka" %% "akka-actor" % akkaV,
"com.typesafe.akka" %% "akka-testkit" % akkaV,
"com.github.nscala-time" %% "nscala-time" % "1.8.0",
"commons-codec" % "commons-codec" % "1.10",
"com.amazonaws" % "aws-java-sdk" % "1.9.25"
)
}
seq(Revolver.settings: _*)
// put this in to eliminate deduplicate errors in sbt-assembly when making fat JAR
mergeStrategy in assembly <<= (mergeStrategy in assembly) { (old) =>
{
case PathList(ps @ _*) if ps.last endsWith "ArgumentsProcessor.class" => MergeStrategy.first
case PathList(ps @ _*) if ps.last endsWith "MatchersBinder.class" => MergeStrategy.first
case "application.conf" => MergeStrategy.concat
case "unwanted.txt" => MergeStrategy.discard
case x => old(x)
}
}
jarName in assembly := "theBigServer.jar"
mainClass in assembly := Some("servletRunner.Boot")
好的,已修复 - 问题似乎出在我安装 sbt 的方式上。我按照 scala-sbt.org 的 manual installation instructions (which actually just specify unix, and I'd assumed held for linux too.) That caused the problems I was seeing above. I then uninstalled, and reinstalled via apt-get
using their Debian instructions 将它安装到 linux mint 17 上,现在 sbt 工作正常。我没有再花时间尝试修复我的手动安装。也许有办法让它发挥作用。不知道。