I have created new Gradle project, added
apply plugin: \'antlr\'
and
dependencies {
antlr \"org.antlr:antlr4:4.5.3\"
The Gradle sample noted by @Mark Vieira only got me halfway there. I found that I had to specify the package in the header of my ANTLR grammar file in order for everything to be seen in both directions (generated code able to access hand-written code and vice-versa).
grammar MyGrammar;
@header {
package com.mypackage;
}
Prior to switching to Gradle, I had been using the ANTLR plugin in IntelliJ, which filled in the package for me. Upon switching to Gradle, the package went away, which caused problems.
Source: https://stackoverflow.com/a/1655920/1877143