Change sbt output directory

I want to change my output directory for some generated files, in this case the generated objects from the 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 in the directory below:

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

How can I modify the assembly file to output the files below?

 /app/models/ 
+6
source share
1 answer

Check the sourceManaged configuration sourceManaged . Any tasks of the generator generator usually place the material in the file specified by this parameter.

 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 ​​are based on the base “source controlled” value, which, in turn, is based on the cross-target value, which is based on the target value and several others.

You can easily change the value of the compile:source-managed parameter in the definition of the sbt assembly with the setting

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

If you want to configure your setting to another parameter, for example, the base directory of the project, you can use something more similar to

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

Of course, you can find a lot of information on using settings here: http://www.scala-sbt.org/release/docs/Getting-Started/More-About-Settings
edit: Looks like this link is dead. It's been a few years, so I'm not 100% sure, but it's probably close to what the original link was talking about: SBT 0.13 - Build Definition or SBT 1.0 - Build Definition

+9
source

Source: https://habr.com/ru/post/943774/


All Articles