如何在使用 SBT 打包期间而不是在测试期间排除资源 [英] How to exclude resources during packaging with SBT but not during testing

查看:52
本文介绍了如何在使用 SBT 打包期间而不是在测试期间排除资源的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在这样的项目结构中有一堆 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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆