Gradle ANTLR Plugin

From NovaOrdis Knowledge Base
Jump to navigation Jump to search

External

Internal

Overview

ANTLR integrates well with Gradle. A typical layout for a project that relies on an ANTL grammar and associated artifacts is to develop the grammar and the artifacts in a separate module (antlr-grammar) and declare dependencies on the module from all modules that rely on the artifacts.

Recipe

1. Declare an 'antlr-grammar' module. The build.gradle build script of the module is similar to:

apply plugin: 'antlr'

dependencies {

    antlr 'org.antlr:antlr4:4.7.1'
}

2. Other modules depending on grammar-related artifacts should declare their dependencies as follows:

apply plugin: 'java'

dependencies {

    implementation project(':antlr-grammar')
}