Not very knowledgeable myself with Gradle, but generateGrammarSource
uses ANTLR 2.7.x (not sure which version), because if I use it on grammar 2.7, .java files will be generated correctly.
You can always do something similar to use ANTLR 3 and Gradle:
task generateWithANTLR3(type:Exec) { commandLine = ['java', '-cp', 'antlr-3.2.jar', 'org.antlr.Tool', 'T.g'] }
(assuming the ANTLR bit and the grammar file are in the same directory as your Gradle assembly file)
EDIT
And you can also let the Tool
output the generated source files to a specific directory. Next task:
task generateWithANTLR3(type:Exec) { commandLine = ['java', '-cp', 'antlr-3.2.jar', 'org.antlr.Tool', '-o', 'src/x/y/generated/', 'T.g'] }
will put the generated files in src/x/y/generated/
.
source share