I'm trying to generate some sources as described in Generating files.
When I put the following in my build.sbt
, everything works:
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
But when I attempt to do the same thing in a plugin, the task never runs:
object MyPlugin extends AutoPlugin {
override lazy val projectSettings = Seq(
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
)
}
Everything else I put in my plugin seems to work fine, but the source file is never generated.
Am I missing something important?