-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
updated README.md to better explain use and integration
- Loading branch information
1 parent
0f9b851
commit 967bcc3
Showing
1 changed file
with
47 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. |