7

我想更改一些生成文件的输出目录,在本例中是从 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/
4

1 回答 1

11

查看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和其他一些值。

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

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 - 构建定义SBT 1.0 - 构建定义

于 2013-04-27T15:04:18.370 回答