I am considering using thrift as the transport for a server written using the play framework. Thrift must convert the IDL files into java source. With a typical build process (e.g. ant), I know how to create the generated sources before entering the main compilation step. Since Play takes control of the compilation process, I'm not sure how to inject generated sources into the build process, or even if it is possible. Is there a way to create additional build steps for Play, or will I simply have to make sure that my thrift files are updated manually?
Play 2 uses SBT as Build tool, so you can use the full SBT power: http://www.scala-sbt.org/release/docs/Howto/generatefiles.html
Add in Build.scala in the setting() block a source generator:
val main = PlayProject(appName, appVersion, appDependencies, mainLang = SCALA).settings(
sourceGenerators in Compile <+= sourceManaged in Compile map { dir =>
//example for one scala file, call your thrift generation here for multiple files
val file = dir / "demo" / "Test.scala"
IO.write(file, """object Test extends App { println("Hi") }""")
Seq(file) //list your generated files here
}
)