1

I work on a Scala + SBT based project.

I am trying to package a the project which contains multiple submodules into a runnable fat-jar. I am using sbt-assembly plugin with the following build.sbt file:

... Project initializations...

osName := "win"

lazy val javafxVersion = "14"

libraryDependencies ++= Seq(...Managed dependencies...)

assemblyMergeStrategy in assembly := {
    case PathList("META-INF", xs@_*) => MergeStrategy.discard
    case x => MergeStrategy.first
}

assemblyJarName in assembly := s"${name.value}_${version.value}.jar".replace("-SNAPSHOT", "")

I need the merge strategy above otherwise I get tens of thousands of conflicts. However, when it comes to managed dependencies that are modularized (contain module-info.class) file, it will pick the first one. This creates a problem as there are 19 dependencies that are actually modularized (JavaFX being an example).

I tried creating my own custom merge strategy but am not an expert when it comes to SBT. I was wondering if there is a better solution to this or am I going to have to create a custom one?

I searched for a while now, I couldn't find a solution, however this GitHub link suggests sbt-assembly doesn't offer a ready-to-go solution for this.

Shobe
  • 33
  • 5
  • Have you tried dropping them to see what happens? I had this same issue before but, as I was creating a fat jar for my application, dropping module-info.class file was not a problem – Rodrigo Vedovato Oct 08 '20 at 21:17
  • https://stackoverflow.com/questions/54834125/sbt-assembly-deduplicate-module-info-class – Rodrigo Vedovato Oct 08 '20 at 21:18
  • @RodrigoVedovato yeah, unfortunately I need it for runtime, the jar won't run otherwise. – Shobe Oct 09 '20 at 08:31
  • Does this answer your question? [sbt assembly: deduplicate module-info.class](https://stackoverflow.com/questions/54834125/sbt-assembly-deduplicate-module-info-class) – Tomer Shetah Oct 12 '20 at 07:48
  • @TomerShetah, no, sorry sir, this would mean I would have to replace sbt-assembly with my own plugin. – Shobe Oct 12 '20 at 16:03

0 Answers0