I wish to add a custom source generator to sbt and use it along with scalapb, the Scala protocol buffer generator. Each works by itself. However when both are combined the project fails to compile the first time after a clean. If I run compile again, it succeeds.
name := "Foo root project"
scalaVersion in ThisBuild:= "2.12.1"
sourceGenerators in Compile += Def.task {
val file = (sourceManaged in Compile).value / "demo" / "Test.scala"
IO.write(file, """object Test extends App { println("Hi") }""")
Seq(file)
}.taskValue
PB.targets in Compile := Seq(
scalapb.gen() -> (sourceManaged in Compile).value
)
The error message:
[error] source file '/ ... /target/scala-2.12/src_managed/main/demo/Test.scala' could not be found
[error] one error found
[error] (compile:compileIncremental) Compilation failed
To reproduce this error you will need at least one proto file in src/main/protobuf.
It puzzles me that two source generators, my custom task and scalapb would conflict. Shouldn't they just both write to the src_managed directories? Am I missing some fundamental sbt concept?