Over the past few Gradle releases we have seen very different behavior in regards to its Antlr support for various versions. We happen to use both Antlr 2 and Antlr 4.5 in different projects and have had a massively hard time standardizing to any single version of Gradle across them. What are the plans for Antlr support in Gradle 3?
I would find it very helpful if you could expand on the sorts of errors you’re getting with Antlr 4.5 with Gradle 3.0 M2. Could you please provide a build scan or at least a stack trace?
Production ANTLR grammar files. If the ANTLR grammar is organized in packages, the structure in the antlr folder should reflect the package structure. This ensures that the generated sources end up in the correct target subfolder.
But that is what I have. Yet this set up fails using Antlr 4.5 + any Gradle version newer than 2.4. The underlying problem, as far as I can tell, is that for some reason the lexical token file is created in the source dir and then Antlr tries to find it in the builddir:
HqlLexer.tokens actually is generated and does exist, but it was generated as /home/sebersole/projects/hibernate/hibernate-semantic-query/src/main/antlr/org/hibernate/sqm/parser/hql/internal/antlr/HqlLexer.tokens (src/main versus build/generated-src/antlr/main/). Also notice that the package dir structure is missing in terms of where Antlr is looking for it
I have reproduced what you’re seeing. According to my testing, Gradle 2.6 works but 2.7 does not.
I have assigned https://issues.gradle.org/browse/GRADLE-3345 to myself and will continue investigating it. We’re branching for Gradle 3.0 tomorrow, so a fix would be more likely in 3.1.
I believe I had similar issues with gradle and antlr4. The issue I have is that the compiler cannot find the class files. They currently live in the default package; I believe the compiler should be able to find them there by default. Please advise, if this is indeed the same issue. .
I am using Gradle with Eclipse Buildship, Gradle Jdk 1.8+
Schalk, I am going to try adopting your solution and adapting it to HIbernate’s build. But I am confused on this CeylonAntlr.Generate#antlrGroup concept. Could you explain that? Or even point me to a usage of it?
This is so that we can manage Antlr and it’s associated transitive dependencies in a different configuration. We then use this configuration later on to set up the classpath for the javaexec project extension.
I think you are describing the antlr Configuration you create for adding Antlr dependencies. I am not asking about that. I asked about antlrGroup which seems to be how you pass the grammars-to-be-processed into the task.
Schalk, oh you are using some older version of Antlr Your rewrite does not work at all with Antlr 4 (4.5 at least). I’ve been picking away at it, but there is a lot to change.