如何将自定义目录添加到 Scala SBT 项目? [英] How to add custom directory to Scala SBT project?

查看:29
本文介绍了如何将自定义目录添加到 Scala SBT 项目?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们的项目中有 conf 目录,这很好,但是新组件之一需要将其自己的配置放入 config 目录中,我们无法更改那个要求.在我的 build.scala 中,我添加了以下行:

We have conf directory in our project which is fine, but one of the new components requires its own config to be placed into config directory and we can't change that requirement. In my build.scala I added the line:

unmanagedResourceDirectories in Compile += baseDirectory.value / "config",

在 SBT 中,当我运行 $ inspect tree package-src 时,我可以看到 compile:unmanagedResourceDirectories 部分下的 config 目录,该目录位于 <代码>compile:packageSrc::mappings 部分.

In SBT when I run $ inspect tree package-src I can see the config directory under compile:unmanagedResourceDirectories section which is under compile:packageSrc::mappings section.

然后我尝试通过运行 $ publishLocal 在本地检查部署包.结果 .zip 包中缺少目标 config 目录.

Then I try to check the deployment package locally by running $ publishLocal. The target config directory is missing in the result .zip package.

我错过了什么/做错了什么?

What did I miss / do wrong?

推荐答案

这是我添加到我的 Build.scala 中以最终解决问题的内容:

This is what I added to my Build.scala to finally solve the issue:

mappings in Universal ++= (baseDirectory.value / "config" * "*" get) map
  (x => x -> ("config/" + x.getName)),

这篇关于如何将自定义目录添加到 Scala SBT 项目?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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