将特定目录及其内容添加到通用目标 [英] Add specific directory and its content to Universal target
问题描述
我正在从 maven 切换到 sbt 以用于我正在处理的 Scala 项目.我曾经使用 Maven 程序集插件,您可以在其中将工作区中的任何目录映射到程序集中的目标目录.我在 sbt-native-package 中没有找到任何等效项,值得为 Universe 类型提供此功能.
I am switching from maven to sbt for a Scala project I am working on. I used to work with the maven assembly plugin where you can map any directory in the workspace to a target directory in the assembly. I didn't find any equivalent in sbt-native-package, it worth provide this feature for the Universe kind.
我知道通用子目录中存在的所有内容都被复制到包中,它就像一个魅力,但我缺少类似以下代码段的内容.
I understood that everything that is present in the universal subdirectory is copied to the package as such, and it works like a charm, but I lack something like the following snippet.
mappings in Universal += {
directory("my/local/dir") -> "static/dirInPackage"
}
我想知道是否已经有办法做到这一点,在这种情况下,我很乐意知道如何去做,如果你愿意,我建议我帮助提交该部分的文档.如果没有办法进行这种定制,我很乐意在讨论了规范后提出一个补丁.
I would like to know if there is already a way to do that, in such case, I would be happy to know how to do it, and I propose my help to commit documentation for that part if you want. If there is no way to do this kind of customization, I will be happy to propose a patch for that after having discussed specifications.
顺便说一句,干得好,你的打包员工作得很好,谢谢!
By the way, great job, your packager is working very well, thanks !
推荐答案
在与 sbt-native-manager 团队讨论和第一个被拒绝"的拉取请求之后,这里是在构建中执行此目录映射的方法.sbt 文件(参见拉取请求 https://github.com/sbt/sbt-native-packager/pull/160 提供模式详细文档):
After having discussed with the sbt-native-manager team and a first "rejected" pull request, here is the way to do this directory mapping in the build.sbt file (see pull request https://github.com/sbt/sbt-native-packager/pull/160 which provides mode detailed documentation) :
mappings in Universal <++= (packageBin in Compile, target ) map { (_, target) =>
val dir = target / "scala-2.10" / "api"
(dir.***) pair relativeTo(dir.getParentFile)
}
为了减少上述代码段的冗长,有一个问题(https://github.com/sbt/sbt-native-packager/issues/161) 提出一种更易读的方式来表达此目录映射:
To reduce verbosity of the above snippet, there is an issue (https://github.com/sbt/sbt-native-packager/issues/161) to propose a more human readable way to express this directory mapping:
mappings in Universal ++= allFilesRelativeTo(file(target / "scala-2.10" / "api"))
这篇关于将特定目录及其内容添加到通用目标的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!