When ANTLR parsers (e.g. the text parser and the tree parser) share token vocabularies through the importVocab/exportVocab options, ANTLR plugin does not recognize this as a dependency. As the result, the generated sources may not work as expected if some new tokens are added or tokens are re-arranged in the file with the exportVocab option. I don't know of a work-around that does not involve manual deletion of files or a clean build.
See http://www.antlr.org/doc/vocab.html
for information on importVocab/exportVocab.
Steps to reproduce the bug:
1. Create a maven project
2. Unzip the attached file into the src/main directory. This will create antlr directory with two files, bug.g and bugtree.g, in it.
3. Add maven-antlr-plugin to the POM with <grammars>bug.g,bugtree.g</grammars>
4. Run mvn compile
5. Find the BugTokensTokenTypes.java and BugTreeTokenTypes.java in the generated-sources directory; verify that in both files FALSE=4 and TRUE=5
6. Open bug.g file and uncomment the lines that define and reference the token called "NOTHING" (there are comments next to both places); save the file.
7. Run mvn compile again. Note that the plugin does not run antlr for bugtree.g, saying that the grammar is up to date
8. Verify that BugTokensTokenTypes.java and BugTreeTokenTypes.java set different values for the token TRUE: it is 6 in the newly generated BugTokensTokenTypes, but the old BugTreeTokenTypes still says TRUE=5.
Expected behavior:
Ideally, the plugin should recognize that the import vocabulary has changed and rerun the antlr for the file(s) with the corresponding importVocab option. Alternatively, rebuilding all grammars from the list when any of the sources is newer than its corresponding output grammar would be acceptable.
This has been fixed in
MANTLR-29