I want to change my output directory for some generated files, in this case generated objects from an XSD-Schema.
Here is part of my Build file.
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
)
This code puts my generated files into the below directory:
target/scala-2.10/src_managed/main/models/
How can I change my buildfile to output the files to below instead?
/app/models/
Check out the sourceManaged
setting key. Any source generator tasks will generally put stuff in the file specified by that setting.
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
Note that the "compile" and "test" values base themselves off of the base "source-managed" value, which is in turn based on the value of cross-target
, which is based on the value of target
and a few others.
You can easily change the value of the compile:source-managed
setting in an sbt build definition with the setting
sourceManaged in Compile := file("app/models")
If you want to base your setting off of another setting, like the project's base directory, you could use something more like
sourceManaged in Compile <<= baseDirectory { _ / "app/models" }
Of course, you can find plenty of info on using settings here: http://www.scala-sbt.org/release/docs/Getting-Started/More-About-Settings
edit: Looks like that link is dead. It's been a few years so I'm not 100% sure, but this is probably close to what the original link talked about: SBT 0.13 -
Build definition or SBT 1.0 - Build definition