【问题标题】:sbt include custom directory in packagesbt 在包中包含自定义目录
【发布时间】:2017-02-02 14:26:26
【问题描述】:

我是 sbt 的新手,我想在最终包中包含一个自定义文件夹。基于一些好的阅读,我了解 sbt 遵循特定的文件夹结构,并且不包括自定义文件夹,除非在构建文件中指定。

以下是项目文件夹结构,希望将 bin 和后续文件包含到最终包中,但这似乎对我不起作用。任何意见表示赞赏

LICENSE  README.MD  app/  build.sbt  conf/  lib/  project/  public/  bin/

我在 sbt 构建文件中尝试过的部分

import com.typesafe.sbt.SbtNativePackager.Universal
mappings in Universal += {
 file("bin") -> "bin"
}

【问题讨论】:

    标签: sbt sbt-native-packager


    【解决方案1】:

    MappingsHelper 对象正是您所需要的。基本上它是 SBT 路径查找器的更好 API。

    import com.typesafe.sbt.SbtNativePackager.autoImport.NativePackagerHelper._
    
    // without top level dir
    mappings in Universal ++= contentOf(baseDirectory.value / "bin")
    
    // with top level dir
    mappings in Universal ++= directory(baseDirectory.value / "bin")
    

    更新 从 sbt 1.2.x 开始,这些帮助程序位于 sbt Io 包中,并且在没有 sbt 本机打包程序的情况下也可用。

    干杯, 渚

    【讨论】:

      【解决方案2】:

      这对我有用 :-) 参考:How to add custom directory to Scala SBT project?

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

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2014-09-24
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2011-11-28
        • 2019-06-22
        • 1970-01-01
        • 2023-03-14
        相关资源
        最近更新 更多