I'm getting the following error between different versions of joda-time, one loaded by elastic search, the other loaded by the current module (and also other modules).
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
I tried shading (didn't work) but after reading it seems that the best option should be excluding transitive dependencies but this doesn't work either (same error) (build.sbt; the complete build.sbt is at https://gist.github.com/meddulla/b1ec2d2c47577ee7f549a40ad8c40a88):
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")
It looks like elastic search's joda-time is not being excluded..
For context, I'm getting this when building the debian package (sbt debian:packageBin
which builds a fat jar using assembly)
Any ideas on how to fix this?
UPDATE
I do have a fix now but it's not one I'm happy with. Basically force the use elasticsearch's version everywhere
dependencyOverrides += "joda-time" % "joda-time" % "2.8.2"
and then in assemblyMergeStrategy use the 1st
assemblyMergeStrategy in assembly := {
case PathList("org", "joda", "time", "base", "BaseDateTime.class") => MergeStrategy.first
case x =>
val oldStrategy = (assemblyMergeStrategy in assembly).value
oldStrategy(x)
}
Any one have any ideas why the exclude wasn't working? Thanks!