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

LSP isn't resolving the dependencies because the version is determined dynamically through Groovy functions #3305

Open
mmilos87 opened this issue Oct 24, 2024 · 0 comments

Comments

@mmilos87
Copy link

I have some problems when I need to initialize a project.
In a Gradle project in the dependency :
dependencies {

... other dependencies
implementation "com.example:my-lib:${getVer()}"
}

static def getVer() {
def branchMap = [ "dev":"0.0.1", "uat": "0.0.2","master": "0.0.3"]
for (e in branchMap) {
if (getBranch().trim().startsWith(e.key.trim())) {
return e.getValue().trim()+"-SNAPSHOT"
}
}
return branchMap.get("master").trim() +"-SNAPSHOT"
}

static def getBranch() {
def branch = "git branch --show-current".execute()
branch.waitFor()
return branch.text
}
...
When I initialize the LSP jdtls server, I have errors that dependency from com.example:my-lib was missing.
When I change the getBranch() function to return, for example, "dev", errors do not show up.
One more thing, nothing is wrong with the Java project because that error is not shown in IntelliJ Idea.
here is my config

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',
"-javaagent:".. mason_packages .. "/lombok.jar",
'-Xms1g',
'--add-modules=ALL-SYSTEM',
'--add-opens', 'java.base/java.util=ALL-UNNAMED',
'--add-opens', 'java.base/java.lang=ALL-UNNAMED',
'-jar', launcher_jar,
'-configuration', mason_packages .. "/config_linux",
'-data', workspace_dir,
},
root_dir = project_root_dir,
capabilities = capabilities,
init_options = {
bundles = bundles
},
settings = {
java = {
maven = {
downloadSources = true,
updateSnapshots = true
},
implementationsCodeLens = {
enabled = true,
},
referencesCodeLens = {
enabled = true,
},
references = {
includeDecompiledSources = true,
},
import = {
gradle = {
enabled = true,
version = "8.10.2",
annotationProcevssing = {
enabled = true,
},
wrapper = {
enabled = true,
},
user = {
home = os.getenv("HOME") .. "/.gradle",
}
},
maven = {
enabled= true,
},
},
inlayHints = {
parameterNames = {
enabled = "all", -- literals, all, none
},
},
format = {
enabled = true,
settings = {
url = os.getenv("HOME") .. "/.config/nvim/res/jdtls-style.xml",
profile = "GoogleStyle",
},
},
configuration = {
updateBuildConfiguration = "automatic",
maven = {
userSettings = null
},
},
signatureHelp = {
enabled = true,
description = {
enabled = true,
},
},
contentProvider = { preferred = 'fernflower' },
extendedClientCapabilities = extendedClientCapabilities,
completion = {
favoriteStaticMembers = {
"org.hamcrest.MatcherAssert.assertThat",
"org.hamcrest.Matchers.",
"org.hamcrest.CoreMatchers.
",
"org.junit.jupiter.api.Assertions.",
"java.util.Objects.requireNonNull",
"java.util.Objects.requireNonNullElse",
"org.mockito.Mockito.
",
},
importOrder = {
"java",
"javax",
"com",
"org"
},
},
sources = {
organizeImports = {
starThreshold = 9999,
staticStarThreshold = 9999,
},
},
codeGeneration = {
toString = {
template = "${object.className}{${member.name()}=${member.value}, ${otherMembers}}",
},
useBlocks = true,
},
eclipse = {
downloadSources = true,
}
},
},

}

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

1 participant