Question

Being new to sbt and the sbt-assembly plugin I am confused about how one deals with builds involving different class definitions within dependencies I am trying to package.

[error] (*:assembly) deduplicate: different file contents found in the following:
[error] /Users/dm/.ivy2/cache/org.apache.tika/tika-app/jars/tika-app-1.3.jar:javax/xml/XMLConstants.class
[error] /Users/dm/.ivy2/cache/stax/stax-api/jars/stax-api-1.0.1.jar:javax/xml/XMLConstants.class
[error] /Users/dm/.ivy2/cache/xml-apis/xml-apis/jars/xml-apis-1.3.03.jar:javax/xml/XMLConstants.class

I've added:

mergeStrategy in assembly <<= (mergeStrategy in assembly) { (old) =>
  {
    case PathList("javax", "xml", xs @ _*) => MergeStrategy.first
  }
}

to my build.sbt file, but I'm still getting the error above (regardless of whether or not it's in the build file). Any guidance would be greatly appreciated.

Thanks,

Don

Was it helpful?

Solution

I think you're close. Make sure that you add any rewiring after assemblySettings are loaded, and also pass any patterns you're not handling to the default strategy:

assemblySettings

mergeStrategy in assembly <<= (mergeStrategy in assembly) { (old) =>
  {
    case PathList("javax", "xml", xs @ _*) => MergeStrategy.first
    case _ => old
  }
}

OTHER TIPS

Just an update—with current sbt (0.13.8) and sbt-assembly (0.13.0) versions, Eugene's code becomes:

assemblyMergeStrategy in assembly := {
  case PathList("javax", "xml", xs @ _*) => MergeStrategy.first
  case x =>
    val oldStrategy = (assemblyMergeStrategy in assembly).value
    oldStrategy(x)
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top