3

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?

Ross Ridge
  • 38,414
  • 7
  • 81
  • 112

2 Answers2

3

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)
}
Yuval Itzchakov
  • 146,575
  • 32
  • 257
  • 321
  • Actually I thought that the line before that the one with `endsWith ".conf"` would take care of that (Yes, I see that it doesn't concat!) but alas... thanks! –  Oct 22 '17 at 08:54
  • Still gives me the exact same error message though :( (yes, sbt was refreshed) –  Oct 22 '17 at 08:58
  • @Sorona I think we're getting the path wrong. Try: `case "reference-overrides.conf" => MergeStrategy.concat` – Yuval Itzchakov Oct 22 '17 at 09:00
  • Same, but maybe we are looking for the wrong file somehow? `[warn] Merging 'reference.conf' with strategy 'concat' [error] 1 error was encountered during merge` -> and then it shows the path to `reference-overrides.conf` –  Oct 22 '17 at 09:05
  • @Sorona Ok, thats good, that means it finds the file. What does the error say? – Yuval Itzchakov Oct 23 '17 at 04:33
  • Sorry, I guess I explained that wrongly. It's the exact same error as before. I also tried to add a `println` "log" there, but no luck :( –  Oct 23 '17 at 13:24
0

I faced the same problem and solved it by adding the following to .

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