Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
Petersoj opened this issue Aug 10, 2024 · 1 comment

Comments

@Petersoj
Copy link

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

@Petersoj
Copy link
Author

Petersoj commented Aug 10, 2024

Update: Reinstalling the extension appears to have fixed this issue. Not sure why it happened in the first place though. Will leave this issue open for now. Feel free to close this issue if you can't reproduce it.
Another update: The issue appears intermittent. Hard to exactly reproduce. But this is still an issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant