Maven build fails with Kotlin and Antlr4


#1

I am trying to get a Maven build working for a project that has both Kotlin and Maven code aboard. I added the Antlr4 plugin and the Kotlin plugin to my build and added
<sourceDir>${project.basedir}/target/generated-sources/antlr4</sourceDir>
to the kotlin plugin configuration because it does not see the Antlr4 generated sources by default.

The kotlin plugin now “sees” the Antlr4 generated .java files, but it reports compilation errors like:
[ERROR] Failed to execute goal org.jetbrains.kotlin:kotlin-maven-plugin:1.1.1:compile (compile) on project grimoire-ui: Compilation failure: Compilation failure: [ERROR] Supertypes of the following classes cannot be resolved. Please make sure you have the required dependencies in the classpath: [ERROR] class to.etc.grimoire.ui.model.load.dbListener, unresolved supertypes: ParseTreeListener [ERROR] class to.etc.grimoire.ui.model.load.dbParser.TypeContext, unresolved supertypes: ParserRuleContext [ERROR] class to.etc.grimoire.ui.model.load.dbParser, unresolved supertypes: Parser [ERROR] class to.etc.grimoire.ui.model.load.dbParser.TableContext, unresolved supertypes: ParserRuleContext [ERROR] class to.etc.grimoire.ui.model.load.dbParser.ColumnListContext, unresolved supertypes: ParserRuleContext [ERROR] class to.etc.grimoire.ui.model.load.dbParser.ColumnContext, unresolved supertypes: ParserRuleContext
These classes are part of Antlr4’s runtime, which has been included as a dependency in the project - but which is apparently not seen properly? I ran Maven with -X and can see that the .jar has been passed in the classpath.

Can anyone help me with what I’m doing wrong?

Thanks in advance :wink: