Dealing with assembly duplicate in generated project

Hi,

I generated a sample project with scala3(3.5.0), zio, zio-http and zio-json. I added sbt-assembly to build a fat jar and and immediately had a duplicate error i’m not sure how to deal with.

[error] 1 error(s) were encountered during the merge:
[error] java.lang.RuntimeException:
[error] Deduplicate found different file contents in the following:
[error]   Jar name = zio-json_3-0.7.1.jar, jar org = dev.zio, entry target = deriving.conf
[error]   Jar name = circe-generic_3-0.14.6.jar, jar org = io.circe, entry target = deriving.conf

I’m not using circe so I’m guessing this is clashing with something internal to tapir. What’s the best way to resolve this?

For now, I’ve just done:

    case PathList(ps @ _*) if ps contains "deriving.conf" =>
      MergeStrategy.discard

Hi @fayi, are you sure you want both circe-generic and zio-json in your project? The conflict is not related to tapir, but it’s caused by these two JSON libs being both in your dependency path. Both libs seem to use the same file name for their derivation configurations.

I certainly dont want that but i’m not adding any dependency to the generated ones.

val dependencies = Seq(
  "com.softwaremill.sttp.tapir" %% "tapir-zio-http-server" % tapirVersion,
  "com.softwaremill.sttp.tapir" %% "tapir-prometheus-metrics" % tapirVersion,
  "com.softwaremill.sttp.tapir" %% "tapir-swagger-ui-bundle" % tapirVersion,
  "com.softwaremill.sttp.tapir" %% "tapir-json-zio" % tapirVersion,
  "ch.qos.logback" % "logback-classic" % "1.5.6",
  "dev.zio" %% "zio-logging" % "2.1.15",
  "dev.zio" %% "zio-logging-slf4j" % "2.1.15",
  "com.softwaremill.sttp.tapir" %% "tapir-sttp-stub-server" % tapirVersion % Test,
  "dev.zio" %% "zio-test" % "2.0.13" % Test,
  "dev.zio" %% "zio-test-sbt" % "2.0.13" % Test,
  "com.softwaremill.sttp.client3" %% "zio-json" % "3.9.7" % Test
)

The circe dependency comes from tapir-swagger-ui-bundle, as that’s what we are using to serialise the open api spec to yaml.

As for this error, you should be able to resolve it by configuring sbt-assembly to properly handle this kind of duplicate file:

ThisBuild / assemblyMergeStrategy := {
  case "deriving.conf" => MergeStrategy.concat
  case x =>
    val oldStrategy = (ThisBuild / assemblyMergeStrategy).value
    oldStrategy(x)
}
1 Like

Thanks! Appreciate the help