First add a custom resolver to your project/plugins.sbt
file.
resolvers +=
Resolver.url(
"bintray-plugins",
url("https://dl.bintray.com/resisttheurge/sbt-plugins/")
)(Resolver.ivyStylePatterns)
Then declare a dependency on the plugin in your project/plugins.sbt
file.
addSbtPlugin("io.zastoupil" % "sbt-antlr-plugin" % "0.2.0")
Then enable the plugin in your built.sbt
file
enablePlugins(AntlrPlugin)
Once the plugin has been added to your project, you can run the antlr
task from the command line.
Navigate to your project's root directory and enter the following lines:
> sbt antlr
Currently, there is no output to signify success or failure outside of antlr's own reporting mechanisms. This will change in future releases.
Integration with sbt compilation is optional. If you want to have the sources generated by the antlr
task be available during sbt compilation, you have to declare the antlr
task as a dependency of the
sbt compile
task in your build.sbt
file.
compile in Compile <<= (compile in Compile).dependsOn(antlr)
Additionally, you have to declare the antlr output directory as a managed source directory for its contents
to be available to the sbt compile
task in your build.sbt
file.
managedSourceDirectories in Compile += antlrBaseOutputDirectory.value
When using an IDE that is capable of reading sbt projects, it is also recommended that you declare the antlr
source directory as an unmanaged source directory in your build.sbt
file.
unmanagedSourceDirectories in Compile += antlrSourceDirectory.value
While this does not impact the execution of the plugin, it does allow your IDE of choice to recognize the antlr source directory as a source directory.