Skip to content

Commit 08ed54b

Browse files
committed
Explicitly compile production code with java 8
This configures the main toolchain of the project to java 17, but it overrides the compiler for the compileJava task to use java 8, so compatibility with older java versions is guaranteed. Gradle will now except dependencies that require newer java versions even if only test code is using newer versions, but this shouldn't be a problem since compilation should fail if incompatible classes are used in production code.
1 parent c9c01a8 commit 08ed54b

1 file changed

Lines changed: 7 additions & 7 deletions

File tree

conventions/src/main/kotlin/tel.schich.javacan.convention.base.gradle.kts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,20 +10,20 @@ javaComponent.withVariantsFromConfiguration(configurations["testFixturesRuntimeE
1010

1111
java {
1212
toolchain {
13-
languageVersion = JavaLanguageVersion.of(8)
14-
}
15-
16-
testing {
17-
toolchain {
18-
languageVersion = JavaLanguageVersion.of(25)
19-
}
13+
languageVersion = JavaLanguageVersion.of(17)
2014
}
2115
}
2216

2317
tasks.test {
2418
useJUnitPlatform()
2519
}
2620

21+
tasks.compileJava {
22+
javaCompiler = javaToolchains.compilerFor {
23+
languageVersion = JavaLanguageVersion.of(8)
24+
}
25+
}
26+
2727
tasks.withType<JavaCompile>().configureEach {
2828
options.compilerArgs.addAll(
2929
listOf(

0 commit comments

Comments
 (0)