antlr4-gradle-plugin
antlr4-gradle-plugin copied to clipboard
Antlr4 plugin for Gradle
= Antlr4 Gradle Plugin :antlr4-url: http://www.antlr.org/ :issues: https://github.com/melix/antlr4-gradle-plugin/issues :gradle-url: http://gradle.org/
image:https://travis-ci.org/melix/antlr4-gradle-plugin.png?branch=master["Build Status", link="https://travis-ci.org/melix/antlr4-gradle-plugin"]
**This plugin is unmaintained. Since its release official support for Antlr 4 has been added to Gradle. See https://docs.gradle.org/current/userguide/antlr_plugin.html#header **
The antlr4-gradle-plugin provides an easy way to generate grammars with {antlr4-url}[Antlr4] using {gradle-url}[Gradle].
== Installation
Use the following snippet inside a Gradle build file:
[source,groovy] .build.gradle
buildscript { repositories { maven { name 'JFrog OSS snapshot repo' url 'https://oss.jfrog.org/oss-snapshot-local/' } jcenter() }
dependencies {
classpath 'me.champeau.gradle:antlr4-gradle-plugin:0.1'
}
}
repositories { jcenter() }
apply plugin: 'me.champeau.gradle.antlr4'
== Configuration
The plugin adds a new task named antlr4. This task exposes 5 properties as part of its configuration
[horizontal]
source:: where the source grammars are. Type: File. Default: src/main/antlr4.
output:: where generated sources go. Type: File. Default: $buildDir/generated-src.
listener:: generate parse tree listener. Type: boolean. Default: true
visitor:: generate parse tree visitor. Type: boolean. Default: true
extraArgs:: extra arguments to pass to the antlr4 tool. Type: List. Default: empty. Example: extraArgs=['-Werror']
== Usage === Basic generation
Generating grammars can be done by calling the antlr4 task:
gradle antlr4
=== Dependency on generated sources
In general, you will want your main project to depend on the generated sources for compilation. You can easily do
this by adding this configuration into your build.gradle:
[source,groovy] .build.gradle
// make the Java compile task depend on the antlr4 task compileJava.dependsOn antlr4
// add the generated source files to the list of java sources sourceSets.main.java.srcDirs += antlr4.output