1

I try to create a fat jar using sbt assembly and I get the following error:

[warn] Merging 'org\eclipse\persistence\descriptors\copying' with strategy 'rename'
[warn] Merging 'META-INF\MANIFEST.MF' with strategy 'discard'
[warn] Merging 'META-INF\maven\commons-logging\commons-logging\pom.properties' with strategy 'discard'
[warn] Merging 'META-INF\maven\commons-logging\commons-logging\pom.xml' with strategy 'discard'
[warn] Merging 'META-INF\maven\javax.validation\validation-api\pom.properties' with strategy 'discard'
[warn] Merging 'META-INF\maven\javax.validation\validation-api\pom.xml' with strategy 'discard'
[warn] Merging 'META-INF\maven\joda-time\joda-time\pom.properties' with strategy 'discard'
[warn] Merging 'META-INF\maven\joda-time\joda-time\pom.xml' with strategy 'discard'
[warn] Merging 'META-INF\maven\org.apache.commons\commons-dbcp2\pom.properties' with strategy 'discard'
[warn] Merging 'META-INF\maven\org.apache.commons\commons-dbcp2\pom.xml' with strategy 'discard'
[warn] Merging 'META-INF\maven\org.apache.commons\commons-pool2\pom.properties' with strategy 'discard'
[warn] Merging 'META-INF\maven\org.apache.commons\commons-pool2\pom.xml' with strategy 'discard'
[warn] Merging 'META-INF\maven\org.glassfish\javax.json\pom.properties' with strategy 'discard'
[warn] Merging 'META-INF\maven\org.glassfish\javax.json\pom.xml' with strategy 'discard'
[warn] Merging 'META-INF\maven\org.joda\joda-convert\pom.properties' with strategy 'discard'
[warn] Merging 'META-INF\maven\org.joda\joda-convert\pom.xml' with strategy 'discard'
[warn] Merging 'META-INF\maven\org.slf4j\slf4j-api\pom.properties' with strategy 'discard'
[warn] Merging 'META-INF\maven\org.slf4j\slf4j-api\pom.xml' with strategy 'discard'
[error] 1 error was encountered during merge
[trace] Stack trace suppressed: run last *:assembly for the full output.
[error] (*:assembly) deduplicate: different file contents found in the following:
[error] C:\Documents and Settings\kp\.ivy2\cache\org.eclipse.persistence\javax.persistence\jars\javax.persistence-2.1.1.jar:META-INF/eclipse.inf
[error] C:\Documents and Settings\kp\.ivy2\cache\org.eclipse.persistence\commonj.sdo\jars\commonj.sdo-2.1.1.jar:META-INF/eclipse.inf

my dependencies are

Seq(
  "com.typesafe.akka" %% "akka-actor" % "2.3.15",
  "org.eclipse.persistence" % "eclipselink" % "2.6.2" % "provided" , 
  "org.scalikejdbc" %% "scalikejdbc" % "2.3.5",
  "org.scalaz" %% "scalaz-core" % "7.2.5"
)

The cause of the problem seems to be commonj.sdo-2.1.1.jar

kostas
  • 1,959
  • 1
  • 24
  • 43

2 Answers2

4

If same path files have diffrent contents, sbt-assembly throws error.

You can avoid or solve this error by selecting merge strategy.

add below code in your build.sbt

assemblyMergeStrategy in assembly := {
      case PathList("META-INF", "eclipse.inf") => MergeStrategy.last
      case x =>
        val oldStrategy = (assemblyMergeStrategy in assembly).value
        oldStrategy(x)
}

you should check out https://github.com/sbt/sbt-assembly#merge-strategy

0

What you need to do is to define the Merge Strategy of your program.

Se here this answer: assembly-merge-strategy issues using sbt-assembly

Community
  • 1
  • 1
Thiago Baldim
  • 7,362
  • 3
  • 29
  • 51