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

Prevent jdtls from building and cleaning output folders? #2074

Closed
RKBK opened this issue Apr 28, 2022 · 4 comments
Closed

Prevent jdtls from building and cleaning output folders? #2074

RKBK opened this issue Apr 28, 2022 · 4 comments
Labels

Comments

@RKBK
Copy link

RKBK commented Apr 28, 2022

I'm experimenting with JDTLS on a Java PDE project via lsp-java in emacs. I am trying to, as a first step, just get feedback from the language server about e.g. completions, errors, go-to-definition, etc. However, I do not want JDT.LS to actually build the code and output any changes to the build folders.

This is for two reasons. First, I'm not confident that I'll be able to, at least initially, set up the build configuration correctly in JDT.LS. I want to run the Eclipse IDE on the side and have it build the code. Eclipse has file hooks that I hope will cause it to see changes. In addition, we have site-specific extensions for the Eclipse IDE that I need to use at least for now. Second, I am running emacs and JDT.LS under windows subsystem for linux, while my code and the Eclipse IDE actually runs under Windows.

I have been able to turn off automatic building (the argument "lsp-java-autobuild-enabled" is set to nil in lsp-java). However, I see in the log from JDTLS, that it cleans output folders, and complains about errors when trying to delete:

Problems encountered while deleting resources. org.eclipse.core.internal.resources.ResourceException: Problems encountered while deleting resources.

These deletion errors are either because of Eclipse IDE locking the files, or, more likely, because WSL isn't able to delete files from the windows partition (I believe this is a known limitation in WSL). If I could just not have JDTLS change the built code in the projects, I hope I could avoid this JDTLS issue.

However, I don't just have issues in JDTLS. I notice that Eclipse IDE complains about inconsistent type hierarchies after I've launched JDTLS in emacs. Furthermore, I'm no longer able to launch the application from Eclipse IDE after launching JDTLS in emacs. I get errors about
org.osgi.framework.BundleException: Could not resolve module
for one of the modules we're using. I'm guessing that JDTLS simply tries to output code, but I've set the build configuration incorrectly for JDTLS, so it fails to do so correctly.

I have also noticed that JDTLS changes the .project files, to add filteredResources tags. This is a nuisance too, but I don't think that changes the Eclipse-IDE-built code.

Is there a e.g. a vmargument for JDTLS, that will cause it to not clean output folders, save new compiled code, or otherwise change the code in the repository?

@snjeza
Copy link
Contributor

snjeza commented May 4, 2022

I want to run the Eclipse IDE on the side and have it build the code

@RKBK You can't open the same workspace with two Eclipse instances. JDT LS is also an Eclipse instance.
You may want to take a look at #1010 and #978

@jdneo jdneo added the question label May 5, 2022
@RKBK
Copy link
Author

RKBK commented May 10, 2022

I'm actually now finding that I /can/ work with both Eclipse and JDT.LS running at the same time. Eclipse doesn't complain about "Bundle exception". I'm not sure what I'm doing different, but I guess the lsp-java-autobuild-enabled being set to nil is working OK after all. I have not been able to get rid of the changes to the .project files.

I looked at the issues you linked, @snjeza . I don't actually notice issues from having Eclipse and JDT.LS running at the same time, so I'm not sure what the locking does or how it should work.

I think it makes sense to, optionally, be able to easily run JDT.LS in a "passive mode". This is basically what I described above. The language server only provides feedback and context information (e.g. for "go to definition") when coding, but doesn't actually compile any code or force any changes to the build environment. Why make it so you can't edit code from several editors at once, if for any reason you'd want to do that? I guess the origin of JDT.LS in Eclipse explains why JDT.LS would want to "lock" the workspace, but from my experience with other language servers for other languages, this is not the behavior I expected.

For now, I'm just going to ask if there is a way to have JDT.LS not change the .project files?

@snjeza
Copy link
Contributor

snjeza commented May 10, 2022

I don't actually notice issues from having Eclipse and JDT.LS running at the same time, so I'm not sure what the locking does or how it should work.

@RKBK It is not supported. You can try to start two Eclipse instances in the same workspace. JDT LS allows it, but you can face unexpected issues. #1010 fixes it.

@RKBK
Copy link
Author

RKBK commented May 12, 2022

@snjeza I understand that JDTLS cannot work in a "read-only" mode, and requires making changes to the code to function. I think this is unfortunate, and I'd like to reiterate that a JDTLS that can work in a "passive mode" would be useful to me.

For now, thank you @snjeza for your responses! I'm closing this issue.

@RKBK RKBK closed this as completed May 12, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants