This is a follow on topic to two other topics:
- Gradle 2.7 & 2.8 causing ANTLR Panic Cannot find importVocab file
- Antlr 4 behavior change between Gradle 2.4 and 2.7
We successfully use the antlr plugin to compile ANTLR4 grammars, but when I upgraded us to any gradle version >= 2.7 we got the following output:
user@dev:/srv/myproj_src$ ./gradlew test
:generateGrammarSource
error(7): cannot find or open file: ../../antlr/myproj/sqlparser/SQL.g4
error(7): cannot find or open file: ../../antlr/myproj/sqlparser/SQL.g4
:generateGrammarSource FAILED
After many hours of troubleshooting, I was able to come up with a workaround for this regression…I moved the file from src/antlr/myproj/sqlparser/SQL.g4
-> src/main/antlr/SQL.g4
and made the same trivial pathing change in my SourceSets block.
- antlr { srcDir 'src/antlr' }
+ antlr { srcDir 'src/main/antlr' }
Hopefully someone smarter than I can use this information to determine how the directory finding stuff got FUBAR’d for ANTLR4 in gradle 2.7 as well as offer a workaround in the meantime. Perhaps its time for some test cases which use directories other than “src/main” to test pathing?