scala - SBT,在构建的 jar 中包含整个外部目录(带有目录本身)

标签 scala build sbt

我需要在我的 SBT 生成的 JAR 文件中包含来自外部位置的整个 static 目录(具有可选的文件夹重命名)。

将它的路径添加到 unmanagedResourceDirectories 只会添加它的内容,而不是整个目录,这会导致 JAR 根目录中的 static 内容。我正在玩各种映射,但没有运气。

有没有人有类似的用例,可以为我指明正确的操作方向?

我不能修改生成 static 目录的进程,也不能使用它的父目录,因为它里面有我不想要的其他文件/目录。

最佳答案

好的,我在 sbt 的 gitter channel 上得到了一点提示,整理了它。所以 mappings 是我需要的:

mappings in (Compile, packageBin) := {
  val statics = contentOf(baseDirectory.value / "static").map {
    case (file, dest) => file -> s"webapp/$dest"
  }
  (mappings in (Compile, packageBin)).value ++ statics
}

这将从 static 目录中获取所有内容,并将其放入生成的 JAR 文件的 webapp 目录中

关于scala - SBT,在构建的 jar 中包含整个外部目录(带有目录本身),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51614886/

相关文章:

scala - 这个操作的好名字是什么?

scala - Actor : How to efficiently handle read-moSTLy data

c++ - Lazy C++——先有鸡还是先有蛋的问题

scala - Apache Spark 项目的 "./sbt/sbt assembly"错误 "Not a valid command: assembly"

scala - 在scala.js中, "Error: Cannot find module ' jsdom'”的可能原因是什么?

Heroku 部署 play 2.1 应用程序非常慢(欧盟区域)

generics - 如何在 Scala 中的泛型类型上指定 Float 和 Double 的类型绑定(bind)?

Android构建系统: How to include prebuilt files from a . tar文件?

build - Jenkins:更新 SCM 而不触发构建?

scala - 无法使用 scalamock 模拟 WSRequest.post()