1
votes

I try to create a fat jar with sbt and sbt-assembly plugin for my project with Scala and EclipseLink JPA, but the assembly command failed, because the eclipse.inf file will found twice.

> assembly
[info] Including from cache: commonj.sdo-2.1.1.jar
[info] Including from cache: javax.persistence-2.1.0.jar
[info] Including from cache: scala-library.jar
[info] Including from cache: eclipselink-2.5.1.jar
[info] Run completed in 38 milliseconds.
[info] Checking every *.class/*.jar file's SHA-1.
[info] Merging files...
[warn] Merging 'org\eclipse\persistence\descriptors\copying' with strategy 'rename'
[warn] Merging 'META-INF\MANIFEST.MF' with strategy 'discard'
[trace] Stack trace suppressed: run last *:assembly for the full output.
[error] (*:assembly) deduplicate: different file contents found in the following:
[error] C:\Users\u987\WebApps\gr\lib_managed\jars\org.eclipse.persistence\javax.persistence\jav    ax.persistence-2.1.0.jar:META-INF/eclipse.inf 
[error] C:\Users\u987\WebApps\gr\lib_managed\jars\org.eclipse.persistence\commonj.sdo\commonj.sdo-2.1.1.jar:META-INF/eclipse.inf

My build.sbt looks like:

import AssemblyKeys._

name := "TelegramReceiver"

version := "0.1"

scalaVersion := "2.10.3"

retrieveManaged in ThisBuild := true

libraryDependencies ++= Seq(
  "org.scalatest" % "scalatest_2.10" % "2.0" % "test",
  "org.eclipse.persistence" % "eclipselink" % "2.5.1" 
)

I try to solve the problem with the mergeStrategy from the sbt assembly plugin, but it doesn't work. I use sbt 0.13.1.

Thanks in advance for help!

1
Could you provide an example of your merge strategy and desired outcome. Do you have eclipse.inf with exact same contents, if not which one do you want to keep?yǝsʞǝla

1 Answers

2
votes

You can add to your settings a custom merge strategy like this:

  mergeStrategy in assembly <<= (mergeStrategy in assembly) { (old) =>
  {
    case PathList("eclipse.inf") => MergeStrategy.rename // use any of the available strategies like `first`
    case x => old(x)
  }}

See this doc for more details.