sbt / sbt-xjc

SBT plugin to compile an XML Schema with XJC
Other
15 stars 14 forks source link

Doc request: how to best add generated sources to compilation? #18

Open bbarker opened 7 years ago

bbarker commented 7 years ago

It was fairly easy to get sbt-xjc to generate sources, but I don't know how to get sbt to compile the generated sources (I could probably devise a way, but as an SBT newbie, I thought it best to ask here).

I stuck this in my build.sbt but it doesn't seem to do much:

sourceGenerators in Compile <+= (xjc in Compile)

I'm in the process of migrating from Maven to SBT for this project, so not everything is well understood by me (or my IDE) yet, sorry if this is silly.

bbarker commented 7 years ago

To make things a bit more concrete, I have the following sub-project that houses the xsd files:

lazy val `dairy-econ-model-api` = ProjectName("dairy-econ-model-api","dairy-econ-model-api").settings(
  libraryDependencies ++= Seq(`org.mockito_mockito-core` % "test" ,
   `junit_junit` % "test" ,
   `javax.persistence_persistence-api` % "provided" ,
   `com.intellij_annotations`),
    name := "dairy-econ-model-api",
    version := "0.0.1-SNAPSHOT",
    organization := "edu.cornell.ansci"
).settings().dependsOn(`dairy-econ-util`)
$ find ./ -name '*.xsd'
./dairy-econ-model-api/src/main/resources/simulation-config.xsd
./dairy-econ-model-api/src/main/resources/simulation-params.xsd

After running sbt:xjc I get generated source files, e.g.,

./dairy-econ-model-api/target/scala-2.11/src_managed/main/edu/cornell/ansci/dairy/simulation/config/Ingredient.java