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

Add bazel support #543

Closed
benoitf opened this issue Feb 6, 2018 · 11 comments
Closed

Add bazel support #543

benoitf opened this issue Feb 6, 2018 · 11 comments

Comments

@benoitf
Copy link

benoitf commented Feb 6, 2018

Bazel build tool (https://bazel.build) is a cross-language build platform allows to have fast and reliable builds.

It could be nice if java projects using WORKSPACE and BUILD would be supported through jdt.ls or an extension.

@fbricon
Copy link
Contributor

fbricon commented Feb 6, 2018

A quick look at https://github.com/bazelbuild/eclipse tells me we can't even embed that plugin into jdt.ls, since it depends on Eclipse UI.

@simon0191
Copy link

simon0191 commented Jun 14, 2019

@fbricon I may be able to work on this, so, What needs to be done in order to add support for Bazel?

  • Are the .classpath files the only thing that is required by the lang server?
  • Is the .project file required?
  • Is there any documentation around the schema for both .classpath and .project?

@simon0191
Copy link

An interesting approach: https://gist.github.com/wolfgangmeyers/49d8edaa763f5fcdcdf7
(I just found it but haven't tried it though)

@simon0191
Copy link

Another reference script that can be used to better understand the schema of .classpath and .project and how to generate them, although this script is for Buck projects:

https://gerrit.googlesource.com/gerrit/+/refs/heads/master/tools/eclipse/project.py

@Stupremee
Copy link

Are there any plans to implement this?

@fbricon
Copy link
Contributor

fbricon commented Aug 8, 2019

@Stupremee Sorry but we're a very small team and have no immediate plans to work on this. Someone from the community needs to step up and help with providing that feature.

@simon0191 sorry for the late reply. In order for this to work, you have 2 options:

  • either generate .project and .classpath as part of your bazel build (effectively reverse engineering the file generation process), so outside of jdt.ls. The python file is one such example.
  • or generate a project (including .project/.classpath) using the Eclipse JDT APIs only, via a project importer implementation (defined in plugin.xml). The logic to generate the project using JDT probably exists in https://github.com/bazelbuild/eclipse. Maybe @damienmg could provide some guidance on how to reuse some of the bazel/eclipse integration bits.
    Eventually, Bazel support doesn't necessarily need to be implemented in jdt.ls core anyway, it
    could be defined in a 3rd party extension (although that might require new APIs from jdt.ls).

@rgrunber
Copy link
Contributor

Closing this out since necessary API for JDT-LS has been implemented in #1404. Feel free to re-open if we've missed something.

@notpeter
Copy link

Note, the linked PR which closed this issue was not merged. Same with a subsequent attempt:

There is another open issue and a discussion:

Does anyone know the state of this jdt.ls infrastructure work which was meant to enable the subsequent implementation of Bazel support? I know there are potential Bazel solutions with additional extensions for Eclipse and maybe VSCode, but I'm curious what would be required to implement Bazel support for jdt.ls running under Neovim or Zed. And whether it is possible to consider implementing support for Bazel directly in jdt.ls without requiring external helper daemons/processes.

Thanks

@fbricon
Copy link
Contributor

fbricon commented Dec 16, 2024

@notpeter maybe @guw can provide some pointers on how to use https://github.com/salesforce/bazel-eclipse alongside jdt.ls in vim or zed

@guw
Copy link
Contributor

guw commented Dec 17, 2024

@notpeter
Copy link

notpeter commented Dec 17, 2024

@guw These are exactly the links I needed.

I don't know if VIM or Zed have support for Java Extension to an extension like VS Code?

The Zed Java Extension handles setting up jdtls and provides syntax highlighting via tree-sitter-java but otherwise is much less feature rich than redhat-developer/vscode-java (unsurprising since vscode-java got an 8 year head start 😉 ).

Here's what I understand from those links:

The salesforce/bazel-vscode-java extension downloads p2-repository.zip which it then extracts, does some renaming and puts them under ~/.vscode/extensions/sfdc.bazel-vscode-java-1.4.0/server. And since salesforce/bazel-vscode-java exports a list of those jars via contributes.javaExtensions in it's package.json those settings are available to other extensions.

When redhat-developer/vscode-java starts the language server it pulls from contributes.javaExtensions and provides those as a bundles array under the initializationOptions when starting jdtls.
Source: redhat-developer/vscode-java:/src/extension.ts

This was extremely helpful and might be enough for me to get this going in Zed:

@fbricon and @guw Thank y'all very much for your help. 🙌

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

No branches or pull requests

7 participants