sbt-assembly: How do I exclude the configuration files in src/main/resources

岁酱吖の 提交于 2019-12-05 02:27:12

问题


I am using sbtassembly from https://github.com/sbt/sbt-assembly to package my project.

I'm wondering is there anyway to exclude the resource files?


回答1:


You can specify files (and paths) to exclude by customizing the mergeStrategy: https://github.com/sbt/sbt-assembly#excluding-specific-files

So for discarding specific file you can do something like this:

// build.sbt

assemblyMergeStrategy in assembly := {
  case PathList("about.html") => MergeStrategy.discard
  case x =>
    val oldStrategy = (assemblyMergeStrategy in assembly).value
    oldStrategy(x)
}

Here's the documentaion for all available strategies: https://github.com/sbt/sbt-assembly#merge-strategy




回答2:


Using Dani's approach with sbt 0.13.13, the config files were still included in my jar. This worked, though:

excludeFilter in Compile := "myconfig.conf",

In my case, all the files have the same name, myconfig.conf, but exist within a tree structure under src/main/resources/config. I tried:

unmanagedResourceDirectories in Compile += { baseDirectory.value / "src/main/resources/config" },

But it removed the directories from the jar, leaving the files.

It's documented here: http://www.scala-sbt.org/0.13/docs/Howto-Customizing-Paths.html



来源:https://stackoverflow.com/questions/35162016/sbt-assembly-how-do-i-exclude-the-configuration-files-in-src-main-resources

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!