Gradle ANTLR Plugin: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
(→Recipe) |
||
(3 intermediate revisions by the same user not shown) | |||
Line 9: | Line 9: | ||
=Overview= | =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: | |||
<syntaxhighlight lang='groovy'> | |||
apply plugin: 'antlr' | |||
dependencies { | |||
antlr 'org.antlr:antlr4:4.7.1' | |||
} | |||
</syntaxhighlight> | |||
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'> | |||
apply plugin: 'java' | |||
dependencies { | |||
implementation project(':antlr-grammar') | |||
} | |||
</syntaxhighlight> |
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')
}