sbt-assembly "deduplicate: different file contents found" in CI
sbt-assembly builds a fat jar and found the same file path in two or more dependency jars with different contents. Its default strategy cannot pick one, so it fails and lists the conflicting jars. You resolve it with a merge strategy for that path.
What this error means
The assembly task fails with "deduplicate: different file contents found in the following:" followed by two or more jar paths for the same resource (often module-info.class or reference.conf).
[error] deduplicate: different file contents found in the following:
[error] .../jackson-core-2.15.2.jar:module-info.class
[error] .../jackson-databind-2.15.2.jar:module-info.classCommon causes
Two jars ship the same path with different bytes
Files like module-info.class, reference.conf, or META-INF entries appear in multiple dependencies with differing contents, so a plain copy is ambiguous.
No merge strategy declared for the path
The default deduplicate strategy errors on differing content; you must tell assembly how to merge or which copy to keep.
How to fix it
Declare a merge strategy for the conflicting paths
- Read the conflicting path from the error.
- Add an
assemblyMergeStrategycase for it (discard, concat, or first). - Re-run
assemblyto confirm the jar builds.
assembly / assemblyMergeStrategy := {
case PathList("module-info.class") => MergeStrategy.discard
case "reference.conf" => MergeStrategy.concat
case x =>
val old = (assembly / assemblyMergeStrategy).value
old(x)
}Remove the duplicate at its source
If the duplicate comes from an unwanted transitive jar, exclude it so only one copy of the path remains.
libraryDependencies += ("com.x" %% "y" % "1.0")
.exclude("com.fasterxml.jackson.core", "jackson-core")How to prevent it
- Declare
assemblyMergeStrategycases for common conflicts (reference.conf,module-info.class). - Keep the fat-jar dependency set minimal to reduce path collisions.
- Build the assembly in CI so merge conflicts surface before release.