sbt-assembly和Play Framework

时间:2017-10-21 21:48:06

标签: scala playframework sbt sbt-assembly

尝试构建一个游戏(2.6.6)+ scala.js应用程序的胖罐,获取

  

[error](play / *:assembly)重复数据删除:在以下内容中找到不同的文件内容:   [error] /home/user/.ivy2/cache/com.typesafe.play/play_2.12/jars/play_2.12-2.6.6.jar:play/reference-overrides.conf   [错误] /home/user/.ivy2/cache/com.typesafe.play/play-akka-http-server_2.12/jars/play-akka-http-server_2.12-2.6.6.jar:play/reference -overrides.conf

build.sbt

mainClass in assembly := Some("play.core.server.ProdServerStart")
//fullClasspath in assembly += Attributed.blank(PlayKeys.playPackageAssets.value)

(灵感来自https://www.playframework.com/documentation/2.6.6/Deploying#Using-the-SBT-assembly-plugin

(但目前不使用playPackageAssets)

我的assembly.sbt仅包含addSbtPlugin("com.eed3si9n" % "sbt-assembly" % "0.14.5")

我也试过“非标准”配置:

assemblyMergeStrategy in assembly := {
// Building fat jar without META-INF
case PathList("META-INF", xs @ _*) => MergeStrategy.discard
// Take last config file
case PathList(ps @ _*) if ps.last endsWith ".conf" => MergeStrategy.last
case o =>
  val oldStrategy = (assemblyMergeStrategy in assembly).value
  oldStrategy(o)
}

但也没有运气。如何解决/一个正确的方法?

2 个答案:

答案 0 :(得分:2)

您需要告诉sbt-assembly如何合并这两个reference-overrides.conf配置文件:

assemblyMergeStrategy in assembly := {
// Building fat jar without META-INF
case PathList("META-INF", xs @ _*) => MergeStrategy.discard
// Take last config file
case PathList(ps @ _*) if ps.last endsWith ".conf" => MergeStrategy.last
case PathList("reference-overrides.conf") => MergeStrategy.concat
case o =>
  val oldStrategy = (assemblyMergeStrategy in assembly).value
  oldStrategy(o)
}

答案 1 :(得分:0)

我遇到了同样的问题,并通过将以下内容添加到其中来解决了该问题。

case PathList("play", "reference-overrides.conf")  => MergeStrategy.concat