Update: My current solution is to use maven-replacer-plugin to remove the public modifier from the generated classes. Worked well enough:
<plugin>
<groupId>com.google.code.maven-replacer-plugin</groupId>
<artifactId>maven-replacer-plugin</artifactId>
<version>1.4.1</version>
<executions>
<execution>
<phase>process-sources</phase>
<goals>
<goal>replace</goal>
</goals>
</execution>
</executions>
<configuration>
<includes>
<include>target/generated-sources/antlr4/**/*.java</include>
</includes>
<variableTokenValueMap>
public class=class,public interface=interface
</variableTokenValueMap>
</configuration>
</plugin>
The version I'm using (1.4.1) is in Maven Central, and a few people have exported the project to GitHub, so there should be no danger of sudden broken builds or lost source code.
That being said, this is still a hack smile
Although even if a hack, would be good enough for me.
Looks like per https://github.com/antlr/antlr4/issues/972 could use maven-replacer-plugin:
Although even if a hack, would be good enough for me.