redhat-developer / redhat-developer/vscode-java
Importing package from non-transitively exposed dependency in Gradle project does not display error
Dieses Issue hat noch niemand übernommen.
- Vorherrschende Sprache
- TypeScript
- Sterne
- 2.3k
- Forks
- 546
- Ø Merge
- 20 Std. 1 Min.
- Gemergte PRs (30 T.)
- 11
Beschreibung
Gradle enables Java library authors to specify what dependencies should be transitively exposed to a consumer using the api or implementation configurations in the dependencies section of the library's build script. When a Gradle application project attempts to use a class from a transitive dependency of a library that has declared that dependency non-transitively exposed (using implementation), the gradle build command fails at the import declaration as expected, but this extension reports no errors in VS Code likely because it sees the dependency on the classpath and ignores its transitive visibility setting. This extension will also provide hinting and code completion for a non-transitively exposed library, which shouldn't be happening.
Environment
- Operating System: macOS/Docker ARM64
- JDK version: OpenJDK Runtime Environment Corretto-21.0.4.7.1
- Visual Studio Code version: 1.91.1 (through code-server)
- Java extension version: 1.33.0 (through OpenVSX)
Steps To Reproduce
- Download the reproduction project.
- Open
Test.javain VS Code and observe no compilation errors reported by this language server extension. - Run
gradle build, which will fail, and observe the compilation errors due toTest.javaattempting to access the class of a non-transitively exposed dependency (com.google.common.base.Preconditionsin the example) of thealpaca-javalibrary.
Reproduction project: workspace.zip
Logs: Log.txt (nothing out of the ordinary)
Current Result
VS Code shows no errors:
Expected Result
IntelliJ does show errors:
Beitragsleitfaden
Erste Schritte
- Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
- Forke das Repository und arbeite in einem Branch.
- Öffne einen Pull Request, der die Issue-Nummer nennt.
Rechercherichtung
Beginnen Sie mit dem angehängten workspace.zip, öffnen Sie Test.java und führen Sie gradle build aus, um dessen Compilerfehler mit den Diagnosen des Language Servers zu vergleichen. Lesen Sie die Einrichtung der Gradle-Abhängigkeiten und Log.txt und verfolgen Sie anschließend die Behandlung der Sichtbarkeit von Abhängigkeiten, sodass der nicht zugängliche Guava-Import einen Fehler erzeugt und keine Hinweise oder Vervollständigungen erhält.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- java, vscode
- Bereich
- build-system, devtools
- Issue-Typ
- Bug
- Schwierigkeit
- 4/5
- Geschätzter Aufwand
- 3-5 Tage
- Aktivitätsstatus
- Veraltet
- Klarheit
- Klar beschrieben
- Anfängerfreundlichkeit
- 35/100