1
votes

I have scala project from which I make jar using 'assembly' command in sbt. I have two application.conf file in one is in scala/main and one is in scala/test folder.

The build jar contains application.conf file from test folder, which I dont want. I want the jar contains application.conf file from scala/main folder.

How to include that file in generated jar using assemble command. pls suggest.

1

1 Answers

3
votes

From the README:

If multiple files share the same relative path (e.g. a resource named application.conf in multiple dependency JARs), the default strategy is to verify that all candidates have the same contents and error out otherwise.

So if it doesn't give you an error, the two files are probably the same. You can customize the behavior, and explicitly exclude one. Here's an example configuration that you can add to your build.sbt:

assemblyMergeStrategy in assembly := {
  case PathList("scala", "test", "resources", "application.conf") =>
    MergeStrategy.discard
  case x =>
    val defaultStrategy = (assemblyMergeStrategy in assembly).value
    defaultStrategy(x)
}