如何在使用 SBT 打包期间而不是在测试期间排除资源 [英] How to exclude resources during packaging with SBT but not during testing
问题描述
我在这样的项目结构中有一堆 conf 文件:
```
src/main/resources/live.confsrc/test/resources/test.conf
```
我想从运行 sbt one-jar(使用 one-jar 插件)时构建的工件中排除 live.conf.我添加了这一行,不幸的是,在运行 sbt test:compile
时也排除了 test.conf<代码>excludeFilter in Runtime in unmanagedResources := "*.conf"
如何在工件 jar 中排除 live.conf 而不是用于测试?
这应该会有所帮助:
mappings in (Compile, packageBin) ~= { _.filter(!_._1.getName.endsWith(".conf")) }
packageBin
是生成 jar 工件的任务,mappings
表示在 Compile
范围内用于编译和项目打包的文件>
I have a bunch of conf files in a project structure like this:
```
src / main / resources / live.conf
src / test / resources / test.conf
```
I want to excluded live.conf from the artifact that is build when I run sbt one-jar (using the one-jar plugin). I added this line which unfortunately also excludes test.conf when running sbt test:compile
excludeFilter in Runtime in unmanagedResources := "*.conf"
How can I exclude live.conf in the artifact jar but not for the tests?
This should help:
mappings in (Compile, packageBin) ~= { _.filter(!_._1.getName.endsWith(".conf")) }
packageBin
is a task which produces your jar artifact and mappings
denotes files wich are used for compilation and project packaging in Compile
scope
这篇关于如何在使用 SBT 打包期间而不是在测试期间排除资源的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!