簡體   English   中英

更改sbt的輸出目錄

[英]Change output directory of sbt

我想更改某些生成文件的輸出目錄,在本例中是從XSD-Schema生成的對象。

這是我的構建文件的一部分。

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/

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

您可以使用該設置輕松更改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
編輯:看起來那個鏈接已經死了。 已經有幾年了,所以我不是百分百肯定,但這可能接近原始鏈接所說的內容: SBT 0.13 - 構建定義SBT 1.0 - 構建定義

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM