mfussenegger / nvim-jdtls

Extensions for the built-in LSP support in Neovim for eclipse.jdt.ls
GNU General Public License v3.0
1.14k stars 62 forks source link

Java argument files #674

Closed Tired-Fox closed 4 months ago

Tired-Fox commented 4 months ago

Problem Statement

I am able to do most things I would want a Java IDE to do. However, this ends when I want to run a test with a really long classpath and the length limit is reached. The workarounds aren't so bad, but require some effort while using the plugin.

Ideas or possible solutions

I propose a toggle in the config to use the argument file feature in java versions 9+. This would mean that the arguments for commands that are run, like for dap or running main, would go into a temporary file and loaded with the argument java @<path to temp file>. This would solve the problems that come with a long classpath in a cli (especially on Windows).

References

mfussenegger commented 4 months ago

java-debug supports a shortenCommandLine option in the launch arguments which you can set to argfile. See https://github.com/microsoft/java-debug/pull/253

To pass it to tests you can call test_nearest_method or test_class with a { config_overrides = { ... } } table.

E.g. the following should work:

jdtls.test_class({
  config_overrides = {
    shortenCommandLine = "argfile",
  }
})
Tired-Fox commented 4 months ago

Thank you for the response! I appreciate all the work that you are doing.