Question

I am pulling my hair using the sbt-jflex plugin to generate Java sources via JFlex, before the main javac phase of sbt (0.12).

The plugin is a clone of the ANTLR plugin, and I found this question which shows how to use the latter.

So I have the following in project/plugins.sbt:

addSbtPlugin("org.scalanlp" % "sbt-jflex" % "0.1-SNAPSHOT") 

And this in ./build.sbt:

jflexSettings

sourceGenerators in Compile <+= generate in jflex

But I must be either doing something wrong, or the javac phase comes before the source generators, because when I run sbt compile, I never see the message "JFlex: Using JFlex version X to generate source files". Instead sbt goes straight to compile the Java sources

[info] Compiling 91 Java sources to ...

And then fails because the JFlex output is missing at that stage. Running source-directories shows that src/main/jflex is indeed included, as is target/src_managed/main.

Était-ce utile?

La solution

After playing around with injecting debug prints, I found that the sbt-jflex plugin assumes sources are in src/main/flex whereas my project has them in src/main/jflex. Adding the following fixes it:

sourceDirectory in jflex <<= (sourceDirectory in Compile) { _ / "jflex" }
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top