scalasbtscalaxb

Configure Scalaxb SBT Plugin's Generated Source Code Location


I've included scalaxb in my project using the sbt-scalaxb plugin. Everything is working great, but I'm not entirely happy with the default location where the source files are being placed. Currently the files are placed in target/scala-2.11/src_managed/main/sbt-scalaxb/scalaxbGenerated (with that last folder what I specified in my build.sbt.

I would prefer to store the source files (though NOT the compiled classes) into src/main/scala/scalaxbGenerated(or something similar). Does anyone know the setting that I can do this with? (I am assuming there is one, I just haven't been able to find it without digging through the scalaxb source code).

Below is mockup of what I mean.

lazy val myProject = (project in file("."))
.enablePlugins(ScalaxbPlugin) // See project/scalaxb.sbt
.settings(commonSettings: _*)
.settings(
    name := "my-project",
    version := myVersion,
    libraryDependencies ++= myDependencies
)
.settings(
    scalaxbDispatchVersion in (Compile, scalaxb) := dispatchCoreVersion,
    scalaxbPackageName in (Compile, scalaxb)     := scalaXbGeneratedCodePackageName
    // TODO - store generated source code in src, not target
)

Solution

  • scalaxb uses the sourceManaged setting (source). You can change this in you build.sbt, for example:

    sourceManaged in (Compile, scalaxb) := (sourceDirectory in Compile).value / "sbt-scalaxb"