Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JDT LS doesn't use the project gradle wrapper #3149

Open
saimanojk1 opened this issue May 5, 2024 · 7 comments
Open

JDT LS doesn't use the project gradle wrapper #3149

saimanojk1 opened this issue May 5, 2024 · 7 comments

Comments

@saimanojk1
Copy link

Jdtls doesn't seem to use the gradle wrapper distribution from gradle properties and this is causing the build to fail. The following is my jdtls configuration for nvim-jdtls:

local status, jdtls = pcall(require, 'jdtls')
if not status then
  vim.notify('jdtls not found', vim.log.levels.WARN)
  return
end
local extendedClientCapabilities = jdtls.extendedClientCapabilities

local config = {
  cmd = {
    'java',
    '-Declipse.application=org.eclipse.jdt.ls.core.id1',
    '-Dosgi.bundles.defaultStartLevel=4',
    '-Declipse.product=org.eclipse.jdt.ls.core.product',
    '-Dlog.protocol=true',
    '-Dlog.level=ALL',
    '-Xmx1g',
    '--add-modules=ALL-SYSTEM',
    '--add-opens',
    'java.base/java.util=ALL-UNNAMED',
    '--add-opens',
    'java.base/java.lang=ALL-UNNAMED',
    '-javaagent:' .. home .. '/.local/share/nvim/lombok.jar',
    '-jar',
    vim.fn.glob(home .. '/.local/share/nvim/mason/jdtls/plugins/org.eclipse.equinox.launcher_*.jar'),
    '-configuration',
    home .. '/.local/share/nvim/mason/jdtls/config_linux',
    '-data',
    workspace_dir,
  },
  root_dir = require('jdtls.setup').find_root { '.git', 'mvnw', 'gradlew', 'pom.xml', 'build.gradle' },

  settings = {
    java = {
      signatureHelp = { enabled = true },
      extendedClientCapabilities = extendedClientCapabilities,
      maven = {
        downloadSources = true,
      },
      gradle = {
        wrapperEnabled = false,
      },
      referencesCodeLens = {
        enabled = true,
      },
      references = {
        includeDecompiledSources = true,
      },
      inlayHints = {
        parameterNames = {
          enabled = 'all', -- literals, all, none
        },
      },
      format = {
        enabled = false,
      },
      jdt = {
        ls = {
          java = { home = "/usr/lib/jvm/java-17-openjdk-amd64/",
          }
        }
      },
      configuration = {
        runtimes = {
          {
            name = "JavaSE-11",
            path = "/usr/lib/jvm/jdk-11/",
            default = true,
          },
          {
            name = "JavaSE-17",
            path = "/usr/lib/jvm/java-17-openjdk-amd64/",
          },
        },
      },
    },
  },

  init_options = {
    bundles = {},
  },
}
require('jdtls').start_or_attach(config)
@fbricon
Copy link
Contributor

fbricon commented May 5, 2024

this should give you a hint:

gradle = {
        wrapperEnabled = false,
}

@saimanojk1
Copy link
Author

I have the same issue even if I toggle it true

@saimanojk1
Copy link
Author

Any updates on this please?

@rgrunber
Copy link
Contributor

Can you try the following path instead of {java = { gradle = { wrapperEnabled = .. } } :

java = {
  import = {
    gradle = {
      wrapper = {
        enabled = true
      }
    }
  }
}

@saimanojk1
Copy link
Author

I tried that just yesterday actually, same issue

java = { 
     import = {
        gradle = {
          java = {
            home = "/usr/lib/jvm/jdk-11/",
          },
          wrapper = {
            enabled = true,
          },
          user = {
            home = "/local/.gradle/gradle.properties",
          },
        }
      },
}

@jdneo
Copy link
Contributor

jdneo commented May 13, 2024

What if you leave the gradle user home empty?

See: https://docs.gradle.org/current/userguide/directory_layout.html#dir:gradle_user_home

@saimanojk1
Copy link
Author

Hi @jdneo doesn't seem to make a difference but good to learn about it. I removed that line.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants