3

I am trying to generate a fat jar using SBT and sbt-assembly. As a requirement, there are other unmanaged resources (directories) that I need to add in the jar. The problem is there are files on 2 directories that have the same file name and path. So running assembly results to a copyResources error - a Duplicate Mappings error. The behaviour that I want is if the file is already existing, discard the other file. Is there a way to do this? Will this work?

unmanagedResources in Compile ~= (_.distinct)

Is it a solution? Is there a better solution?

1 Answers1

1

Maybe the assembly plugin's merge strategy settings are sufficient for you. Try this:

mergeStrategy in assembly <<= (mergeStrategy in assembly) { (old) => {
  case PathList("path", "to", "file", xs @ _*) =>
    (xs map {_.toLowerCase}) match {
      case ("myduplicatefile" :: Nil) => MergeStrategy.first
      case _ => MergeStrategy.deduplicate
    }
  case x => old(x)
}
Christian
  • 4,543
  • 1
  • 22
  • 31