Skip to content

Instantly share code, notes, and snippets.

@stantonk
Created June 12, 2014 04:18
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save stantonk/5303b7ec84b782a58628 to your computer and use it in GitHub Desktop.
Save stantonk/5303b7ec84b782a58628 to your computer and use it in GitHub Desktop.
Black magic to tell sbt to choose the first duplicate class when resolving dependency collisions instead of just failing out.
/**
* Black magic to tell sbt to choose the first duplicate class when resolving dependency collisions instead of just
* failing out.
*/
mergeStrategy in assembly <<= (mergeStrategy in assembly) {
(old) => {
case x if Assembly.isConfigFile(x) =>
MergeStrategy.concat
case PathList(ps@_*) if Assembly.isReadme(ps.last) || Assembly.isLicenseFile(ps.last) =>
MergeStrategy.rename
case PathList("META-INF", xs@_*) =>
(xs map { _.toLowerCase}) match {
case ("manifest.mf" :: Nil) | ("index.list" :: Nil) | ("dependencies" :: Nil) =>
MergeStrategy.discard
case ps@(x :: xs) if ps.last.endsWith(".sf") || ps.last.endsWith(".dsa") =>
MergeStrategy.discard
case "plexus" :: xs =>
MergeStrategy.discard
case "services" :: xs =>
MergeStrategy.filterDistinctLines
case ("spring.schemas" :: Nil) | ("spring.handlers" :: Nil) =>
MergeStrategy.filterDistinctLines
case _ => MergeStrategy.deduplicate
}
case _ => MergeStrategy.first // overrides the default fallback MergeStrategy of deduplicate
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment