Gradle ANTLR Plugin: Difference between revisions

From NovaOrdis Knowledge Base
Jump to navigation Jump to search
Line 11: Line 11:


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.
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:
<syntaxhighlight lang='groovy'>
apply plugin: 'antlr'
dependencies {
    antlr 'org.antlr:antlr4:4.7.1'
}
</syntaxhighlight>
2. Other modules depending on grammar-related artifacts should declare their dependencies as follows:
<syntaxhighlight lang='groovy'>
apply plugin: 'java'
dependencies {
    implementation project(':antlr-grammar')
}
</syntaxhighlight>

Revision as of 20:25, 19 July 2018

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')
}