DeDuplication error with SBT assembly plugin
Asked Answered
A

1

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...

Almsgiver answered 5/12, 2013 at 6:46 Comment(0)
S
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?

Shelbashelbi answered 7/12, 2013 at 1:48 Comment(3)
Below is the actual non working code:gist.github.com/rajeevprasanna/7868988 I wrote the above code by following your instructions at this link : github.com/eed3si9n/sbt-assembly-full-config-sample/blob/master/… Now i have removed bottom three linkes relating to create project. then it worked. Working code : gist.github.com/rajeevprasanna/7868999Almsgiver
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.Shelbashelbi
Thank you for explanation. I am just started learning SBT. I don't have much knowledge in SBT. So got into this issue.Almsgiver

© 2022 - 2024 — McMap. All rights reserved.