0

I currently have a Maven Java 11 project that builds fine. However, I use Eclipse's implementation of the language-server for editing the code within Emacs. This works fine, everything that I really need is available.

However, my question, is how can I disable the Eclipse LSP/compiler from attempting to auto-compile the project? It's not always an issue, but often the JDTLS seems to be recompile everything all the time to the point that when I run Maven, it has to recompile everything again. At best, this is a slowdown in the develop->test cycle. At worst, I have to clean build frequently.

Eclipse has an option in its GUI which "builds automatically". I am curious, is there a text file I can toggle this setting with?

howlger
  • 31,050
  • 11
  • 59
  • 99
kballou
  • 68
  • 1
  • 1
  • 10
  • Disabling incrementally compiling slows down develop->test cycle, since for running a test the code has to be compiled. Better found out, what causes everything to recompile. Maybe you have projects with build cycles causing this. – howlger Sep 08 '22 at 07:22
  • I could understand if I needed to recompile a few files, but not every single file in both the `main` and `test` trees for every `mvn test` invocation. – kballou Sep 08 '22 at 17:00
  • To the other point, this is a very simple project. Single pom project. Granted, there are some antlr grammars which require generating source, but that doesn't seem to induce a cycle. In fact, the output of Maven seems to indicate that if the sources were generated and the grammar files haven't been edited, it doesn't need to regenerate the source files. I'm not sure what requires everything to recompile. My suspicion is Eclipse's JDTLS and Maven not interacting well, thus, the desire to disable the Eclipse side compilation. – kballou Sep 08 '22 at 17:04
  • One final clarification: Maven "recompiles the module" even if I just rerun the test suite *without* making changes. – kballou Sep 08 '22 at 17:10
  • Sure, `mvn test` will compile everything before running your tests. For a fast develop->test cycle, run your tests directly from within Eclipse (so the incremental Java compiler of Eclipse is used; in contrast, Maven uses `javac` by default). – howlger Sep 08 '22 at 19:43
  • I'm not being clear enough. I do not/cannot use Eclipse directly for various reasons not worth unpacking. After reading [this question](https://stackoverflow.com/questions/16963012/maven-compiler-recompile-all-files-instead-modified), I do not want to change what Maven is doing. I simply want to disable Eclipse's compilation pass, ideally without disabling the other static analysis features. – kballou Sep 08 '22 at 21:18
  • Does [lsp-java](https://github.com/emacs-lsp/lsp-java) support directly running of your tests? If yes, choose this way instead of running your tests via Maven. Maven does not support incremental compilation in the sense JDT does. And by the way, [according to the lsp-java documentation](https://github.com/emacs-lsp/lsp-java#supported-settings), the setting you are looking for is `lsp-java-autobuild-enabled`. – howlger Sep 09 '22 at 06:01
  • I'm not sure how I missed that. I think `lsp-java-autobuild-enabled` is what I wanted. I'm not sure I'm seeing what I expect, but thank you! @howlger, you have answered the desired question and have been plenty patient with me! `lsp-java` does have a way to run the tests directly, but part of the desire for disabling the JDT compilation is becuase it doesn't seem to build correctly given all the dependencies and such. Granted, I'm not sure how that works with debugger plugins (which do work). Maybe my issues are somewhere else, entirely possible! – kballou Sep 09 '22 at 18:17

1 Answers1

0

According to the lsp-java documentation, the setting you are looking for is lsp-java-autobuild-enabled.

However, if there is a way to run the tests directly rather than via Maven, it would be faster since Maven does not support incremental compiling like JDT does (ideally, compiling should be done incrementally on save and not when running the application or a test).

howlger
  • 31,050
  • 11
  • 59
  • 99