【问题标题】:Change output directory of sbt更改 sbt 的输出目录
【发布时间】:2013-04-21 13:41:34
【问题描述】:

我想更改一些生成文件的输出目录,在本例中是从 XSD 架构生成的对象。

这是我的构建文件的一部分。

val main = PlayProject(appName, appVersion, appDependencies, mainLang = SCALA,
      settings = Defaults.defaultSettings ++ buildInfoSettings ++ scalaxbSettings
    ).settings(
      sourceGenerators in Compile <+= buildInfo,
      buildInfoKeys := Seq[BuildInfoKey](name, version, scalaVersion, sbtVersion),
      buildInfoPackage := "hello",
      packageName in scalaxb in Compile := "models",
      sourceGenerators in Compile <+= scalaxb in Compile
    )

此代码将我生成的文件放入以下目录:

target/scala-2.10/src_managed/main/models/

如何更改我的构建文件以将文件输出到下面?

/app/models/

【问题讨论】:

    标签: scala playframework sbt playframework-2.1 scalaxb


    【解决方案1】:

    查看sourceManaged 设置键。任何源生成器任务通常会将内容放入该设置指定的文件中。

    source-managed                 - target/scala-2.10/src_managed
    compile:source-managed         - target/scala-2.10/src_managed/main
    test:source-managed            - target/scala-2.10/src_managed/test
    

    请注意,“编译”和“测试”值基于“源管理”基本值,而后者又基于cross-target 的值,而target 的值又基于target 的值和其他一些人。

    您可以使用设置轻松更改 sbt 构建定义中 compile:source-managed 设置的值

    sourceManaged in Compile := file("app/models")
    

    如果你想基于另一个设置来设置你的设置,比如项目的基本目录,你可以使用类似的东西

    sourceManaged in Compile <<= baseDirectory { _ / "app/models" }
    

    当然,您可以在此处找到有关使用设置的大量信息:http://www.scala-sbt.org/release/docs/Getting-Started/More-About-Settings
    编辑: 看起来该链接已失效。已经有几年了,所以我不能 100% 确定,但这可能与原始链接所说的接近:SBT 0.13 - Build definition 或 SBT 1.0 - Build definition

    【讨论】:

    猜你喜欢
    • 2016-09-15
    • 2015-07-25
    • 2011-04-18
    • 2017-01-30
    • 1970-01-01
    • 2022-11-11
    • 2012-04-25
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多