Skip to content

Commit

Permalink
updated README.md to better explain use and integration
Browse files Browse the repository at this point in the history
  • Loading branch information
resisttheurge committed Jun 17, 2015
1 parent 0f9b851 commit 967bcc3
Showing 1 changed file with 47 additions and 13 deletions.
60 changes: 47 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,22 +1,56 @@
sbt-antlr-plugin
===

## Usage
## Getting the plugin
First add a custom resolver to your `project/plugins.sbt` file.
```scala
resolvers +=
Resolver.url(
"bintray-plugins",
url("https://dl.bintray.com/resisttheurge/sbt-plugins/")
)(Resolver.ivyStylePatterns)
```

`project/plugins.sbt`
Then declare a dependency on the plugin in your `project/plugins.sbt` file.
```scala
resolvers += Resolver.url("bintray-plugins", url("https://dl.bintray.com/resisttheurge/sbt-plugins/"))(Resolver.ivyStylePatterns)
addSbtPlugin("io.zastoupil" % "sbt-antlr-plugin" % "0.1.0")
```

`build.sbt`
Then enable the plugin in your `built.sbt` file
```scala
lazy val `your-project` =
(project in file("."))
.enablePlugins(AntlrPlugin)
.settings(
compile in Compile <<= (compile in Compile).dependsOn(antlr),
unmanagedSourceDirectories in Compile += antlrSourceDirectory.value,
managedSourceDirectories in Compile += antlrBaseOutputDirectory.value
)
```
enablePlugins(AntlrPlugin)
```

## Usage
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.

## SBT compilation integration
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.
```scala
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.
```scala
managedSourceDirectories in Compile += antlrBaseOutputDirectory.value
```

## IDE Integration
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.
```scala
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.

0 comments on commit 967bcc3

Please sign in to comment.