redhat-developer / redhat-developer/vscode-java

Importing package from non-transitively exposed dependency in Gradle project does not display error

Aperta
#3,739 1 commento 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Gradle
Lingua principale
TypeScript
Stelle
2.3k
Fork
546
Merge medio
20h 1m
PR unite (30g)
11

Descrizione

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
  1. Download the reproduction project.
  2. Open Test.java in VS Code and observe no compilation errors reported by this language server extension.
  3. Run gradle build, which will fail, and observe the compilation errors due to Test.java attempting to access the class of a non-transitively exposed dependency (com.google.common.base.Preconditions in the example) of the alpaca-java library.

Reproduction project: workspace.zip
Logs: Log.txt (nothing out of the ordinary)

Current Result

VS Code shows no errors:
VS Code

Expected Result

IntelliJ does show errors:
IntelliJ

Guida per i contributori

Apri la guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Direzione di ricerca

Inizia con il workspace.zip allegato, apri Test.java ed esegui gradle build per confrontare i relativi errori del compilatore con le diagnostiche del language server. Leggi la configurazione delle dipendenze Gradle e Log.txt, quindi traccia la gestione della visibilità delle dipendenze in modo che l’import Guava non accessibile produca un errore e non riceva suggerimenti né completamento.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
java, vscode
Ambito
build-system, devtools
Tipo di issue
Bug
Difficoltà
4/5
Tempo stimato
3-5 giorni
Stato di attività
Ferma
Chiarezza
Specificata chiaramente
Idoneità per principianti
35/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.