Skip to content

Commit

Permalink
fix(java): use stable file locations for JARs provided by mason.nvim (#…
Browse files Browse the repository at this point in the history
…245)

Since the introduction of the new registry, packages started linking
more than executables (`bin/`) in Mason's root directory. Examples of
these are platform-agnostic "share" files, for example the JARs used
here.

Reaching into the internal package structures of Mason packages is not
stable and is prone to break across versions.
  • Loading branch information
williamboman authored and Uzaaft committed Jun 11, 2023
1 parent 845244c commit 401c440
Showing 1 changed file with 5 additions and 19 deletions.
24 changes: 5 additions & 19 deletions lua/astrocommunity/pack/java/java.lua
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,6 @@ return {
local workspace_dir = vim.fn.stdpath "data" .. "/site/java/workspace-root/" .. project_name
os.execute("mkdir " .. workspace_dir)

-- get the mason install path
local install_path = require("mason-registry").get_package("jdtls"):get_install_path()

-- get the current OS
local os
if vim.fn.has "mac" == 1 then
Expand All @@ -68,17 +65,17 @@ return {
"-Declipse.product=org.eclipse.jdt.ls.core.product",
"-Dlog.protocol=true",
"-Dlog.level=ALL",
"-javaagent:" .. install_path .. "/lombok.jar",
"-javaagent:" .. vim.fn.expand "$MASON/share/jdtls/lombok.jar",
"-Xms1g",
"--add-modules=ALL-SYSTEM",
"--add-opens",
"java.base/java.util=ALL-UNNAMED",
"--add-opens",
"java.base/java.lang=ALL-UNNAMED",
"-jar",
vim.fn.glob(install_path .. "/plugins/org.eclipse.equinox.launcher_*.jar"),
vim.fn.expand "$MASON/share/jdtls/plugins/org.eclipse.equinox.launcher.jar",
"-configuration",
install_path .. "/config_" .. os,
vim.fn.expand "$MASON/share/jdtls/config",
"-data",
workspace_dir,
},
Expand All @@ -88,20 +85,9 @@ return {
},
init_options = {
bundles = {
vim.fn.glob(
require("mason-registry").get_package("java-debug-adapter"):get_install_path()
.. "/extension/server/com.microsoft.java.debug.plugin-*.jar"
),
vim.fn.expand "$MASON/share/java-debug-adapter/com.microsoft.java.debug.plugin.jar",
-- unpack remaining bundles
(table.unpack or unpack)(
vim.split(
vim.fn.glob(
require("mason-registry").get_package("java-test"):get_install_path() .. "/extension/server/*.jar"
),
"\n",
{}
)
),
(table.unpack or unpack)(vim.split(vim.fn.glob "$MASON/share/java-test/*.jar", "\n", {})),
},
},
handlers = {
Expand Down

0 comments on commit 401c440

Please sign in to comment.