This is an issue when running separate lexer grammar and parser grammar (thus using options { tokenVocab = MyLexer ; }).
File Structure:
Project
| π src
| | π main
| | | π antlr4
| | | | π imports
| | | | π¦ some.package
| | | | | π MyLexer.g4
| | | | | π MyParser.g4
| π target
| | π generated-sources
| | | π antlr4
| | | | π¦ some.package
| | | | | π MyLexer.java
| | | | | π MyParser.java
| | | | π MyLexer.tokens
| | | | π MyParser.tokens
| π pom.xml
The configuration for each .g4 is correct (~ means path to project)
Output directory where all output is generated | ~\target\generated-sources\antlr4
Location of imported grammars | ~\src\main\antlr4\imports
Grammar file encoding; e.g., euc-jp | UTF-8
Package/namespace for the generated code | some.package
Language (e.g., Java, Python2, CSharp, ...) | Java
The IDEA plugin looks for the .tokenss in the folder ~/target/generated-sources/antlr4/some/package, but the maven plugin puts them in ~/target/generated-sources/antlr4.
IMHO, it makes more sense for the .tokens to be generated in the corresponding package where the generated code is located. This means that projects with grammars in multiple packages will have the .tokens files in the folders alongside the generated sources, instead of flat in the root of the generated sources folder.
I've uploaded a zip of a minimal reproduction case to a GitHub Gist. Note that the ANTLR file configuration has a ~ in the paths rather than the path to the project (as I don't know where you're putting the project). https://gist.github.com/CAD97/d607d5b7965b640949c80e9ec3231830
As this is a disagreement between the IDEA plugin and the Maven plugin, I've created this bug on both repositories. antlr/intellij-plugin-v4: antlr/intellij-plugin-v4#293 antlr/antlr4/antlr4-maven-plugin: antlr/antlr4#1593