Using Gradle 2.10's ANTLR plugin to import an ANTLR 4 lexer grammar into another grammar

I had the same problem a few weeks ago. Putting everything into the root (src/main/antlr) did not work for me because I really wanted the generated files to be in a package and the IDE did not pick up the generated files when they were in the wrong place.

It seems, antlr is not able to find the lexer.tokens file when compiling the parser. I also tried to specify the location with the lib parameter similar to this

generateGrammarSource {
arguments = ["-lib", “…/…/…/build/generated-src/antlr/main/my/package”]
}

but this does not work either because antlr checks if the directory exists and the plugin removes it before antlr is called.