Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error with sbt-assembly and Play Framework

Trying to build a fat jar of a play (2.6.6) + scala.js application, getting

[error] (play/*:assembly) deduplicate: different file contents found in the following: [error] /home/user/.ivy2/cache/com.typesafe.play/play_2.12/jars/play_2.12-2.6.6.jar:play/reference-overrides.conf [error] /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)

(Inspired by https://www.playframework.com/documentation/2.6.6/Deploying#Using-the-SBT-assembly-plugin)

(but not using playPackageAssets at the moment)

my assembly.sbt contains just addSbtPlugin("com.eed3si9n" % "sbt-assembly" % "0.14.5")

I also tried with a "non-standard" config:

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)
}

but no luck either. How to fix that the/a correct way?


1 Answers

You need to tell sbt-assembly how to merge these two reference-overrides.conf config files:

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)
}
like image 166
Yuval Itzchakov Avatar answered May 19 '26 22:05

Yuval Itzchakov