Skip to content

Instantly share code, notes, and snippets.

@rgoulter
Last active August 29, 2015 14:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rgoulter/0b8009d99fb1e81ada2e to your computer and use it in GitHub Desktop.
Save rgoulter/0b8009d99fb1e81ada2e to your computer and use it in GitHub Desktop.
SBT for an Antlr4, Scala project. Can generate Eclipse, also.
name := "antlr-scala-c"
version := "0.1.3"
scalaVersion := "2.11.2"
antlr4Settings
antlr4GenListener in Antlr4 := true
antlr4GenVisitor in Antlr4 := true
antlr4Dependency in Antlr4 := "org.antlr" % "antlr4" % "4.5"
// in project/sbt-antlr4.sbt
resolvers += "simplytyped.com" at "http://simplytyped.com/repo/releases"
addSbtPlugin("com.simplytyped" % "sbt-antlr4" % "0.7.3")
@rgoulter
Copy link
Author

"Can generate Eclipse" if SBT Eclipse plugin is installed 'globally'. Derp.

While this is much more terse than a comparable gradle script, the generated Eclipse project won't automatically recognise the Antlr4 file. After a sbt compile, SBT will handle generating the Antlr files (although these don't show up as part of the project's src). There isn't an Antlr-specific task for SBT.
Perhaps with the Antlr4 Eclipse plugin, this could be mitigated by adding src/main/antlr4 as a project src; though probably then SBT and Eclipse would diverge in where Antlr4 generates its sources.
This seems more a vanity complaint than anything else, I guess.

@rgoulter
Copy link
Author

Antlr4 generated src went to target/scala-2.11/src_managed/main.
Generated classes to target/scala-2.11/classes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment