Gradle ANTLR Plugin: Difference between revisions

From NovaOrdis Knowledge Base
Jump to navigation Jump to search
 
(One intermediate revision by the same user not shown)
Line 25: Line 25:
</syntaxhighlight>
</syntaxhighlight>


2. Other modules depending on grammar-related artifacts should declare their dependencies as follows:
2. Place the grammar in the module's ./src/main/antlr.
 
3. Other modules depending on grammar-related artifacts should declare their dependencies as follows:


<syntaxhighlight lang='groovy'>
<syntaxhighlight lang='groovy'>

Latest revision as of 20:26, 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. Place the grammar in the module's ./src/main/antlr.

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

apply plugin: 'java'

dependencies {

    implementation project(':antlr-grammar')
}