作为sbt和sbt-assembly插件的新手,我对如何处理涉及我想要打包的依赖项中的不同类定义的构建感到困惑。
[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
我添加了:
mergeStrategy in assembly <<= (mergeStrategy in assembly) { (old) =>
{
case PathList("javax", "xml", xs @ _*) => MergeStrategy.first
}
}
到我的build.sbt文件,但我仍然得到上面的错误(无论它是否在构建文件中)。任何指导将不胜感激。
谢谢,
唐
答案 0 :(得分:5)
我觉得你很亲密。确保在加载assemblySettings
后添加任何重新布线,并将您未处理的任何模式传递给默认策略:
assemblySettings
mergeStrategy in assembly <<= (mergeStrategy in assembly) { (old) =>
{
case PathList("javax", "xml", xs @ _*) => MergeStrategy.first
case _ => old
}
}
答案 1 :(得分:3)
只是更新 - 使用当前的sbt(0.13.8)和sbt-assembly(0.13.0)版本,Eugene的代码变为:
assemblyMergeStrategy in assembly := {
case PathList("javax", "xml", xs @ _*) => MergeStrategy.first
case x =>
val oldStrategy = (assemblyMergeStrategy in assembly).value
oldStrategy(x)
}