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/
If you have JAR files (unmanaged dependencies) that you want to use in your project, simply copy them to the lib folder in the root directory of your SBT project, and SBT will find them automatically.
Create or open your sbt project. In the Project tool window, in the source root directory, locate the build. properties file and open it in the editor. In the editor explicitly specify the version of sbt that you want to use in the project.
The libraryDependencies key Most of the time, you can simply list your dependencies in the setting libraryDependencies . It's also possible to write a Maven POM file or Ivy configuration file to externally configure your dependencies, and have sbt use those external configuration files.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With