sbt-assembly重复数据删除类

时间:2016-05-09 18:51:33

标签: sbt sbt-assembly sbt-native-packager

我在不同版本的joda-time之间收到以下错误,一个是通过弹性搜索加载的,另一个是由当前模块加载的(还有其他模块)。

java.lang.RuntimeException: deduplicate: different file contents found in the following:
/root/.ivy2/cache/org.elasticsearch/elasticsearch/jars/elasticsearch-2.3.0.jar:org/joda/time/base/BaseDateTime.class
/root/.ivy2/cache/joda-time/joda-time/jars/joda-time-2.8.2.jar:org/joda/time/base/BaseDateTime.class
...
[error] (*:assembly) deduplicate: different file contents found in the following:
[error] /root/.ivy2/cache/org.elasticsearch/elasticsearch/jars/elasticsearch-2.3.0.jar:org/joda/time/base/BaseDateTime.class
[error] /root/.ivy2/cache/joda-time/joda-time/jars/joda-time-2.8.2.jar:org/joda/time/base/BaseDateTime.class

我试过着色(不起作用)但是在阅读之后似乎最好的选择应该是排除传递依赖,但这也不起作用(相同的错误)(build.sbt;完整的build.sbt位于{ {3}}):

libraryDependencies += "joda-time" % "joda-time" % "2.3"
libraryDependencies += "org.joda" % "joda-convert" % "1.7"

...
libraryDependencies += "org.elasticsearch" % "elasticsearch" % "2.3.0" exclude("joda-time", "joda-time")
libraryDependencies += "puregroup.com" %% "puregroup-core" % "0.1-SNAPSHOT" exclude("joda-time", "joda-time")

看起来弹性搜索的joda-time并没有被排除..

对于上下文,我在构建debian包时使用它(sbt debian:packageBin使用程序集构建胖罐)

有关如何解决此问题的任何想法?

更新

我现在确实有一个解决办法,但这不是我很满意的。基本上强制使用elasticsearch的版本无处不在

dependencyOverrides += "joda-time" % "joda-time" % "2.8.2"

然后在assemblyMergeStrategy中使用第1个

assemblyMergeStrategy in assembly := {
  case PathList("org", "joda", "time", "base", "BaseDateTime.class") => MergeStrategy.first
  case x =>
    val oldStrategy = (assemblyMergeStrategy in assembly).value
    oldStrategy(x)
}

任何人都有任何想法为什么排除不起作用?谢谢!

0 个答案:

没有答案