title: How to generate sources in an sbt plugin?
body: <p>I'm trying to generate some sources as described in <a href="http://www.scala-sbt.org/0.13.5/docs/Howto/generatefiles.html" rel="noreferrer">Generating files</a>.</p>
  
  <p>When I put the following in my <code>build.sbt</code>, everything works:</p>
  
  <pre><code>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
  </code></pre>
  
  <p>But when I attempt to do the same thing in a plugin, the task never runs:</p>
  
  <pre><code>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
    )
  }
  </code></pre>
  
  <p>Everything else I put in my plugin seems to work fine, but the source file is never generated.</p>
  
  <p>Am I missing something important?</p>