Skip to content

Java Runtime incorrect, when using gradle toolchains #2804

Open
@levno-710

Description

@levno-710

I am using the following build.gradle file:

plugins {
    // Apply the java-library plugin for API and implementation separation.
    id 'java-library'
}

java {
    toolchain {
        languageVersion = JavaLanguageVersion.of(17)
    }
}

repositories {
    // Use Maven Central for resolving dependencies.
    mavenCentral()
}

dependencies {
    // Use JUnit test framework.
    testImplementation 'junit:junit:4.13'

    // This dependency is exported to consumers, that is to say found on their compile classpath.
    api 'org.apache.commons:commons-math3:3.6.1'

    // This dependency is used internally, and not exposed to consumers on their own compile classpath.
    implementation 'com.google.guava:guava:29.0-jre'

    // Java Parser and Code Generator
    implementation 'com.github.javaparser:javaparser-symbol-solver-core:3.24.7'
}

It uses the Java 1.17 toolchain, however in the Configure Java Runtime Tab, it shows Java Version 12:
Capture

When I try to use newer Java features, it shows the following Error:
The Java feature 'Text Blocks' is only available with source level 15 and above

Environment
  • Operating System: Windows 10
  • JDK version: 1.17
  • Visual Studio Code version:
  • Java extension version: 1.12.0
  • Gradle version: 7.0.0
Steps To Reproduce

Sample Project: java-rewriter.zip

  1. open lib/src/test/java/dev/levno/javarewriter/LibraryTest.java in vscode
  2. Error is shown
Current Result

Error is displayed in File

Expected Result

No Error should be displayed

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions