title: Generating Java Sources with sbt JFlex plugin
body: <p>I am pulling my hair using the <a href="https://github.com/dlwh/sbt-jflex" rel="nofollow noreferrer">sbt-jflex</a> plugin to generate Java sources via JFlex, before the main javac phase of sbt (0.12).</p>
  
  <p>The plugin is a clone of the ANTLR plugin, and I found <a href="https://stackoverflow.com/questions/8425863/sbt-and-antlr-got-simple-example">this question</a> which shows how to use the latter.</p>
  
  <p>So I have the following in <code>project/plugins.sbt</code>:</p>
  
  <pre><code>addSbtPlugin("org.scalanlp" % "sbt-jflex" % "0.1-SNAPSHOT") 
  </code></pre>
  
  <p>And this in <code>./build.sbt</code>:</p>
  
  <pre><code>jflexSettings
  
  sourceGenerators in Compile &lt;+= generate in jflex
  </code></pre>
  
  <p>But I must be either doing something wrong, or the javac phase comes before the source generators, because when I run <code>sbt compile</code>, I never see the message <code>"JFlex: Using JFlex version X to generate source files"</code>. Instead sbt goes straight to compile the Java sources</p>
  
  <pre><code>[info] Compiling 91 Java sources to ...
  </code></pre>
  
  <p>And then fails because the JFlex output is missing at that stage. Running <code>source-directories</code> shows that <code>src/main/jflex</code> is indeed included, as is <code>target/src_managed/main</code>.</p>