VS Code Dependency Resolution for Java
mmatthews06 opened this issue · 7 comments
I am able to build projects using this extension, but I have not been able to get VS Code to resolve external dependencies using anything that I can find in Bazel build artifacts, BUILD files or anything else. Is there a prescribed way to get VS Code to resolve import statements using anything in the Bazel ecosystem, and the VS Code Java extension pack?
Is there's a way to pull all JARs, I could probably add them as "Referenced Libraries" in the Java Projects extension, for example.
Basically, all of my external import
statements are unresolved, and I'd like to know how to fix that. I could work on contributing code if this is something the extension could benefit from.
There's a StackOverflow question about this that has been open for over 2 years:
https://stackoverflow.com/questions/62112254/finding-java-imports-invscode-with-bazel
I feel like there should be a "simple" 5-step process that could resolve this, if it's not something that's trivial to implement in this extension.
This severly limits the usefulness of this extension for Java projects using Bazel... 😿
The topic is a bit more general than only "Dependency Resolution" (for Java import
, and Syntax Completion) for the Language support for Java by Red Hat by automatically configuring Referenced Libraries in Classpath Configuration - it also includes setting the correct Sources folder/s, or Configure Java Runtime (instead of Type: Unmanaged folder) of the JDK version, etc.
I'm wondering how hard it would be to add the missing support. Not sure if belongs more into this project or the Java by Red Hat extension (which already has similar support for Maven & Gradle); but perhaps it could be on either side.
BTW https://bazel.build/install/ide#java recommends the https://github.com/georgewfraser/java-language-server#usage extension by @georgewfraser, which is an alternative Java LS for VSC to the Java by Red Hat one. (But I personally haven't tried it out, yet.)
@guw @AlexeiShmidman @LeonovecSergey how did you go about Bazel-VSC-Java integration in your (unreleased) https://github.com/salesforce/bazel-vscode?
@meteorcloudy @fweikert @jfirebaugh @sheldonneuberger-sc @dierksen @limdor FYI
@vorburger https://github.com/salesforce/bazel-vscode is an extension the the RedHat Java Language Server. It uses parts of https://github.com/salesforce/bazel-eclipse (which uses aspects) to implement the classpath resolution. I'm working on a plan to get this into a releasable state in the next few months.
haven't tried https://github.com/georgewfraser/java-language-server out
I meanwhile did, and ran into some problems.
Bazel-VSC-Java integration in your (unreleased) https://github.com/salesforce/bazel-vscode
a releasable state in the next few months
ACK. I'm trying to locally build it right now, just to see if it's already "good enough" to use as-is.
I will try to make a few contribs to bazel-vscode and bazel-eclipse at least to be able to easily build it.
haven't tried https://github.com/georgewfraser/java-language-server out
I meanwhile did, and ran into some problems.
I couldn't get that extension to work either.
Looks like there's been a issue open request Bazel support in the redhat extension since 2019 redhat-developer/vscode-java#909
@moehajj @vorburger I need some help updating our Bazel VSCode Java extension.
We have a Bazel VSCode Java Extension at https://github.com/salesforce/bazel-vscode-java. It adds Java support for Bazel projects to VS Code based on RedHat's Java extension.
The Bazel Language Server (and the Bazel Eclipse Feature) received a significant overhaul. This update needs to be brought into the VS Code extension. Any contributions are highly appreciated. The language server can be fetched from https://opensource.salesforce.com/bazel-eclipse/latest/
@guw I don't have the bandwidth to actively contribute with code (unfortunately; I would love to, this sounds, but I just don't have time for this; sorry), but salesforce/bazel-vscode-java#49 has new feedback as an end-user testing, which may be helpful.