I'm trying to build an ANTLR project with Maven, the project structure is like
src/main +
|-antlr4
|-fo/bar
|-G1.g4
|-G2.g4
|-imports
in which G1 imports G2 like:
grammar G1;
import G2;
However, when I build with Maven, I get the following error:
[ERROR] Message{errorType=CANNOT_FIND_IMPORTED_GRAMMAR, args=[G2, fo\bar\G1.g4], e=null, fileName='null', line=-1, charPosition=-1}
It works with no problem if I put G1.g4
and G2.g4
directly under antlr4
directory. It seems to me that, when put the Grammar files in a package, it needs special syntax in the import statement.
I noticed the question Antlr4 maven plugin cannot find grammar files in different directories , but here, the grammars are in one directory.