Dependency issues with generated sources using Gradle and ANTLR
UPDATE (Fix):
I've fixed this by adding enough module dependencies in the project settings. This still gets overwritten by a gradle refresh but I don't think this will be a huge deal. However, if anyone knows how to make this fix stick in a robust manner, I'd love to know!
ORIGINAL:
I've tinkered quite a bit, but these tools are complex enough that I'm just gonna ask how they should fit together. I've created a minimal version of my error, which I'm posting on GitHub if that helps (I've included idea files as well).
I am using Gradle to pull in a dependency on ANTLR and running `gradle assemble` to build (this builds fine from command line). However, IntelliJ has a large number of "Cannot resolve symbol 'Parser'" type messages. First, here is my project structure:

Next, here is the generated ExpParser file which is generated from ANTLR:

Two things of note:
- UsedByANTLR, imported on line 4, is in the normal gradle source set location. I have been able to get this to resolve, but only by updating files that get overridden by gradle when I refresh (to be accurate, I've gotten an identical problem to resolve in the full project I'm working on). I'd like a more permanent way to get this to work, but not the end of the world if there isn't one.
- Parser belongs to `org.antlr.runtime` and should be imported on line 7. However, Intellij is indicating that this import statement is unused, and that Parser is unresolved. Further, when entering in `import org.antlr.runtime.` the only completion option is `*`, and I can't specify Parser by its fully qualified name `...extends org.antlr.runtime.Parser`.
How can I get things to play nicely with eachother?
EDIT:
I'm using
-
IntelliJ IDEA 2018.2.2 (Ultimate Edition)
Build #IU-182.4129.33, built on August 21, 2018
Licensed to Benjamin Kushigian
Subscription is active until September 30, 2019
For educational use only.
JRE: 1.8.0_152-release-1248-b8 amd64
JVM: OpenJDK 64-Bit Server VM by JetBrains s.r.o
Linux 4.4.0-142-generic -
------------------------------------------------------------
Gradle 4.8.1
------------------------------------------------------------
Build time: 2018-06-21 07:53:06 UTC
Revision: 0abdea078047b12df42e7750ccba34d69b516a22
Groovy: 2.4.12
Ant: Apache Ant(TM) version 1.9.11 compiled on March 23 2018
JVM: 1.8.0_212 (Oracle Corporation 25.212-b03)
OS: Linux 4.4.0-142-generic amd64 - Java 8
- Antlr 3.5.2
请先登录再写评论。
You can try IntelliJ IDEA 2019.2 with the build delegated to Gradle. If it builds from the command line, it should also work in IntelliJ IDEA.
See https://i.imgur.com/AmWjMZR.png.