lsp-java icon indicating copy to clipboard operation
lsp-java copied to clipboard

Multi module maven project

Open GabCamarda opened this issue 5 years ago • 14 comments

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!

GabCamarda avatar Sep 22 '19 22:09 GabCamarda

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+.

yyoncho avatar Sep 23 '19 07:09 yyoncho

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?

GabCamarda avatar Sep 23 '19 08:09 GabCamarda

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

yyoncho avatar Sep 23 '19 08:09 yyoncho

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?

GabCamarda avatar Sep 23 '19 09:09 GabCamarda

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.

yyoncho avatar Sep 23 '19 19:09 yyoncho

Thanks, I doubt my Lisp can be of any help here, but I can sure give it a try on my spare time.

GabCamarda avatar Sep 23 '19 20:09 GabCamarda

see https://github.com/redhat-developer/vscode-java/issues/1084 and corresponding PR https://github.com/eclipse/eclipse.jdt.ls/pull/1200

yyoncho avatar Oct 07 '19 18:10 yyoncho

Nice, when can we expect this added to lsp-mode/lsp-java ?

GabCamarda avatar Oct 08 '19 12:10 GabCamarda

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.

yyoncho avatar Oct 08 '19 17:10 yyoncho

see redhat-developer/vscode-java#1084 and corresponding PR eclipse/eclipse.jdt.ls#1200

The PR has been merged

GabCamarda avatar Oct 17 '19 13:10 GabCamarda

Here it is a guide how to expose server property: https://github.com/emacs-lsp/lsp-mode#sections

yyoncho avatar Oct 17 '19 15:10 yyoncho

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.

nipuna-perera avatar Mar 24 '22 14:03 nipuna-perera

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.

yyoncho avatar Mar 24 '22 15:03 yyoncho

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.

nipuna-perera avatar Mar 24 '22 16:03 nipuna-perera