lsp-java
lsp-java copied to clipboard
Multi module maven project
I was wondering what is the best way to setup lsp-java in a multi module maven project. It is a mono repo with about 50 services in it, each configured as maven project. I was able to setup the root as the main root of the whole project (the parent maven config), however it takes a while to index all the files and most of the time it throws an "out of memory" error. Increasing the heap size of the VM helps to avoid this problem, however it still takes a long time to build the workspace, during which most of the features I benefit from using lsp-java are unusable. I also disabled file watchers to speed up the process. For reference, using IntelliJ rarely lags.
I appreciate my project has a lot of files and the process of indexing them all is inevitably slower, but Is there anything I can do to help speed up the process at all?
p.s.: thanks for the great work!
You may try import only a limited set of services e. g. do not import the root and then either put .projectile in the service root.
If this is not an option and JDT LS parsing is taking a lot of time, I do not think that there is anything that we can do on emacs side but we should report the issue upstream. IIRC there was a user that reported that he successfully uses lsp-java on 6000+.
Thanks, I've tried that already, however by doing so I cannot jump to file definitions outside of the root. And sometimes that is needed. Unless I'm missing something?
It should be possible to make it work if the other projects are compiled and their source is available in the local .m2 repository. Also, it is possible to attach the source locations in jdtls but this is not exposed in lsp-java - https://github.com/emacs-lsp/lsp-java/issues/71
Yeah I usually build the project at first to make sure all sources are generated. I'll give this a try. Any plans on implementing the "attach source" feature?
Any plans on implementing the "attach source" feature?
Not in the next few weeks, but if you want to give it a hit feel free to ping me.
Thanks, I doubt my Lisp can be of any help here, but I can sure give it a try on my spare time.
see https://github.com/redhat-developer/vscode-java/issues/1084 and corresponding PR https://github.com/eclipse/eclipse.jdt.ls/pull/1200
Nice, when can we expect this added to lsp-mode/lsp-java ?
First, the PR should be merged in jdt ls and then it is a single liner in lsp-java - register the configuration settings like we register the rest of the configuration settings.
see redhat-developer/vscode-java#1084 and corresponding PR eclipse/eclipse.jdt.ls#1200
The PR has been merged
Here it is a guide how to expose server property: https://github.com/emacs-lsp/lsp-mode#sections
What was the resolution to this? I have a similar large multi module project but I don't want lsp context to switch every time I open a file in a submodule. How do I pin the root(parent) folder as project root for the project? I haven't found a good solution for this online.
How do I pin the root(parent) folder as project root for the project?
@nipuna-perera you can import the folder containing the root pom and it should work.
I tried that. It didn't work. I deleted the lsp-session file, then when I was prompted, I chose "Interactively select root". Then picked pom.xml
of my parent. Still when I pick a file from a submodule, the LSP server shows that it's starting, meaning it picked a different project. When I invoke projectile-find-file
I only see selections from the submodule.