jdtls-launcher icon indicating copy to clipboard operation
jdtls-launcher copied to clipboard

Configurable workspace path

Open dsych opened this issue 3 years ago • 1 comments

I jump between java projects quite frequently, which means that each of them need a separate workspace directory. Otherwise, there is a need to clear the workspace dir before every launch, which is sub-optimal.

I got around this issue by applying a patch the the jdtls-launcher.sh, that allow the script to accept an optional workspace directory. So the way it works now is:

  1. Workspace root is unique per project, which is resolved dynamically every time jdtls is to be launched.
  2. this line takes whatever args were passed from cmd and forwards them to run e.g. `run "$@"
  3. Instead of using a hard-coded workspace path here we instead take the arguments passed to the function e.g. --data "$@"

I realize this is a very naive solution, but it works for most of the use cases. I certainly haven't had problems with it so far. Ideally, there should be an option like --workspaceDir or something that would default if not provided. WDYT?

dsych avatar Apr 05 '22 03:04 dsych

I don't quite understand the problem here, there shouldn't be any conflicts by default since the workspace is a root and each project gets its own subdirectory.

For example, this is my Workspace structure:

❯ tree -L 1
.
├── eruizc-dev_a8d6905d
├── jdt.ls-java-project
├── nvim-efm-setup_2e6741e6
├── TCP_conversor_aa60fe8c
├── test_1356b31d
├── test_4c6067d
└── test_de585d96

A hash is also included to prevent conflicts from projects with the same name

I like the solution you provided for changing workspace (assuming we keep backwards compatibility and there's a default value), but are we sure that's the root of your problem?

eruizc-dev avatar Apr 06 '22 02:04 eruizc-dev

Since the per-project workspace isn't much of an issue and the default location ~/.cache/jdtls-workspace is now configurable, I'll close this

Thanks for the issue and PR #20

eruizc-dev avatar Sep 14 '22 17:09 eruizc-dev