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
Use the following snippet inside a Gradle build file:
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'
The plugin adds a new task named antlr4
. This task exposes 5 properties as part of its configuration
source |
where the source grammars are. Type: File. Default: |
output |
where generated sources go. Type: File. Default: |
listener |
generate parse tree listener. Type: boolean. Default: |
visitor |
generate parse tree visitor. Type: boolean. Default: |
extraArgs |
extra arguments to pass to the antlr4 tool. Type: List. Default: empty. Example: extraArgs=['-Werror'] |
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
:
// 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
// add antlr4 to classpath
configurations {
compile.extendsFrom antlr4
}