7

I am trying to create an executable jar using SBT assembly plugin.

I am ending up with below error :

[error] (app/*:assembly) deduplicate: different file contents found in the following:
[error] /Users/rajeevprasanna/.ivy2/cache/org.eclipse.jetty.orbit/javax.servlet/orbits/javax.servlet-3.0.0.v201112011016.jar:about.html
[error] /Users/rajeevprasanna/.ivy2/cache/org.eclipse.jetty/jetty-continuation/jars/jetty-continuation-8.1.8.v20121106.jar:about.html
[error] /Users/rajeevprasanna/.ivy2/cache/org.eclipse.jetty/jetty-http/jars/jetty-http-8.1.8.v20121106.jar:about.html
[error] /Users/rajeevprasanna/.ivy2/cache/org.eclipse.jetty/jetty-io/jars/jetty-io-8.1.8.v20121106.jar:about.html
[error] /Users/rajeevprasanna/.ivy2/cache/org.eclipse.jetty/jetty-security/jars/jetty-security-8.1.8.v20121106.jar:about.html
[error] /Users/rajeevprasanna/.ivy2/cache/org.eclipse.jetty/jetty-server/jars/jetty-server-8.1.8.v20121106.jar:about.html
[error] /Users/rajeevprasanna/.ivy2/cache/org.eclipse.jetty/jetty-servlet/jars/jetty-servlet-8.1.8.v20121106.jar:about.html
[error] /Users/rajeevprasanna/.ivy2/cache/org.eclipse.jetty/jetty-util/jars/jetty-util-8.1.8.v20121106.jar:about.html
[error] /Users/rajeevprasanna/.ivy2/cache/org.eclipse.jetty/jetty-webapp/jars/jetty-webapp-8.1.8.v20121106.jar:about.html
[error] /Users/rajeevprasanna/.ivy2/cache/org.eclipse.jetty/jetty-xml/jars/jetty-xml-8.1.8.v20121106.jar:about.html
[error] Total time: 2562 s, completed Dec 5, 2013 12:03:25 PM

After reading wikis of assembly plugin, i have added merge strategy in build.scala file. Seems it is not working. I am not sure whether it is right fix or not. Can someone suggest me the right strategy.

Below is the code which i have in build.scala file :

mergeStrategy in assembly <<= (mergeStrategy in assembly) {
      (old) => {
        case "about.html" => MergeStrategy.discard
        case "logback.xml" => MergeStrategy.first //case PathList("logback.xml") => MergeStrategy.discard
        case x => old(x)
      }
    }

I have coded plugin integration with my app as per this doc : Standalone deployment of Scalatra servlet

I tried diffrent strategies like MergeStrategy.rename and MergeStrategy.deduplicate. But nothing works.. Looking for help...

Community
  • 1
  • 1
Rajeev
  • 4,762
  • 8
  • 41
  • 63

1 Answers1

1

Your MergeStrategy looks correct. The only unhandled conflicts are "about.html" in the jetty jars, so case "about.html" => MergeStrategy.discard should just do it.

If you're still getting the error, I suspect that re-wiring of the mergeStrategy in assembly setting is either not going in, or going in the wrong order. The only way to know for sure is to see your Build.scala. @Stefan Ollinger's answer to your linked question for example sets up the project as follows:

lazy val project = Project("myProj", file(".")).
  settings(mySettings: _*).
  settings(myAssemblySettings:_*)

Could you post your Build.scala on gist if possible?

Eugene Yokota
  • 94,654
  • 45
  • 215
  • 319
  • 1
    Below is the actual non working code:https://gist.github.com/rajeevprasanna/7868988 I wrote the above code by following your instructions at this link : https://github.com/eed3si9n/sbt-assembly-full-config-sample/blob/master/project/builds.scala Now i have removed bottom three linkes relating to create project. then it worked. Working code : https://gist.github.com/rajeevprasanna/7868999 – Rajeev Dec 09 '13 at 08:20
  • In my example, `buildSettings` only contain essential settings common to all projects like `version` and `organization`, and `assemblySettings` is loaded at `appSettings`. Your first gist loads all sorts of settings to `buildSettings` including `assemblySettings` and it's loaded again at `appSettings`. So you might have read my code, but you did not follow the point of my code. If you just need root level, you'd be better off using `build.sbt`. – Eugene Yokota Dec 10 '13 at 12:27
  • Thank you for explanation. I am just started learning SBT. I don't have much knowledge in SBT. So got into this issue. – Rajeev Dec 10 '13 at 12:52