sbt assembly error encontered during merge

空扰寡人 提交于 2020-01-14 04:08:45

问题


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


回答1:


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




回答2:


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



来源:https://stackoverflow.com/questions/39850368/sbt-assembly-error-encontered-during-merge

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!