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

Wrong JDK used by gradle build server #1635

Closed
HannesFutter opened this issue Nov 29, 2024 · 2 comments
Closed

Wrong JDK used by gradle build server #1635

HannesFutter opened this issue Nov 29, 2024 · 2 comments
Labels
bug Something isn't working

Comments

@HannesFutter
Copy link

HannesFutter commented Nov 29, 2024

Extension Name: vscode-gradle
Extension Version: v3.16.4 and v3.16.2024111106 (pre-release)
OS Version: Windows 11 (23H2)
VSCode version: 1.95.3 (user setup)

JAVA_HOME environment variable set to D:/java/Amazon/21.0.4/win32/x86_64/jdk.
Settings like this:

{
    "java.jdt.ls.java.home": "D:/java/Amazon/21.0.4/win32/x86_64/jdk",
    "java.import.gradle.java.home": "D:/java/Amazon/21.0.4/win32/x86_64/jdk",
    "java.configuration.runtimes": [
        {
            "name": "JavaSE-21",
            "path": "D:/java/Amazon/21.0.4/win32/x86_64/jdk",
            "default": true
        }
    ]
}

I'm developing an extension that runs a gradle task which validates the version of the Java VM it runs in.

The gradle server seems to be started with correct JDK (according to the message in Gradle for Java output channel):

[info] Java Home: D:/java/Amazon/21.0.4/win32/x86_64/jdk

And when triggering the gradle task by double clicking the task item in the gradle task tree view it runs through nicely.

But when I run the task using the vscode-gradle extension API's runTask() it fails.
When using runTask() the default Java-17 JDK shipped with redhat.java is used (the task I'm using reports System.getProperty("java.home") in its error message).

Unfortunately I cannot reproduce the bug without any other extensions as I need redhat.java and vscjava.vscode-java-debug for their task types and debug adapter implementations.

@HannesFutter HannesFutter added the bug Something isn't working label Nov 29, 2024
@HannesFutter
Copy link
Author

I feel this might be related to these:
#1630 (comment)
#1589 (comment)
#1551 (comment)

@HannesFutter
Copy link
Author

Me again, very sorry to have bothered you, I found my mistake:
I was calling runTask() API with workspace-relative project path (instead of absolute path).
Using the absolute path fixed it for me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant