File tree Expand file tree Collapse file tree 1 file changed +14
-0
lines changed Expand file tree Collapse file tree 1 file changed +14
-0
lines changed Original file line number Diff line number Diff line change
1
+ import org.jetbrains.kotlin.gradle.dsl.KotlinJvmProjectExtension
2
+
1
3
project.pluginManager.withPlugin(" java" ) {
2
4
val javaToolchainVersion: String? by project
3
5
val defaultLanguageVersion = JavaLanguageVersion .of(17 )
4
6
val javaLanguageVersion = javaToolchainVersion?.let { JavaLanguageVersion .of(it) } ? : defaultLanguageVersion
5
7
6
8
val extension = the<JavaPluginExtension >()
7
9
val javaToolchainService = the<JavaToolchainService >()
10
+
8
11
extension.toolchain.languageVersion.set(javaLanguageVersion)
12
+
13
+ pluginManager.withPlugin(" org.jetbrains.kotlin.jvm" ) {
14
+ configure<KotlinJvmProjectExtension > {
15
+ jvmToolchain {
16
+ languageVersion.set(javaLanguageVersion)
17
+ }
18
+ }
19
+ }
20
+
9
21
tasks.withType<JavaExec >().configureEach {
10
22
javaLauncher.set(javaToolchainService.launcherFor(extension.toolchain))
11
23
}
24
+
12
25
tasks.withType<JavaCompile >().configureEach {
13
26
outputs.cacheIf { javaLanguageVersion == defaultLanguageVersion }
14
27
doFirst {
@@ -19,6 +32,7 @@ project.pluginManager.withPlugin("java") {
19
32
}
20
33
}
21
34
}
35
+
22
36
tasks.withType<GroovyCompile >().configureEach {
23
37
javaLauncher.set(javaToolchainService.launcherFor {
24
38
// Groovy does not yet support JDK 19, see https://issues.apache.org/jira/browse/GROOVY-10569
You can’t perform that action at this time.
0 commit comments