I have a java 17 Spring Boot project requiring preview features but I can’t get it configured correctly.
In VSC, I have configured my project’s
-
JDK Runtime to use JavaSE-17
-
Compiler to use
-
the ‘–release’ option for cross-compilation
-
the Bytecode version: to 17
-
Here, I have no possibility to enable preview features
-
In my build.gradle
file, I have the following:
// [N]:preview-features - https://docs.gradle.org/current/userguide/building_java_projects.html#sec:feature_preview
tasks.withType(JavaCompile).configureEach {
options.compilerArgs += '--enable-preview'
}
tasks.withType(Test).configureEach {
jvmArgs += '--enable-preview'
}
tasks.withType(JavaExec).configureEach {
jvmArgs += '--enable-preview'
}
Such a setting doesn’t enable me to use preview features of java 22 in my java editor. But, I can compile, test and run my code with Gradle successfully.
Also, I have a problem when I try to use the Spring Boot Dashboard integrated in VSC. If I try to run or debug my project, I get the following in the output window:
> Build starts at 2024-08-14 07:44:34
Task :compileJava started
Task :compileJava failed
------
Could not execute build using connection to Gradle installation '/Users/utilisationnormale/.sdkman/candidates/gradle/current'.
error: invalid source release 17 with --enable-preview
(preview language features are only supported for release 22)
1 error
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':compileJava'.
My Gradle version is 8.9
My VSC version is 1.92.0
My Extension Pack for Java is v0.29.0
My Spring Boot Dashboard for VS Code is v0.14.0
Thanks in advance
hjoly is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.