Compare commits

...
Author SHA1 Message Date
LudyandGitHub d7a03836b9 Merge branch 'main' into centralized_java_toolchain 2026-07-09 23:30:14 +02:00
LudyandGitHub 172cfca95c Merge branch 'main' into centralized_java_toolchain 2026-07-09 11:03:56 +02:00
Ludy87 b3517d3864 Update build.gradle 2026-07-06 17:45:51 +02:00
Ludy87 6595d42f86 Unify Java version config in build.gradle
Extract Java version into a single buildJavaLanguageVersion variable to ensure consistency across all compilation tasks (root, subprojects, and compileRestartHelper). Explicitly configure the javaCompiler for the restart helper task to use the same version.
2026-07-06 16:48:35 +02:00
+16 -8
View File
@@ -47,11 +47,15 @@ ext {
modernJavaVersion = 25 modernJavaVersion = 25
} }
def buildJavaMajorVersion = (project.findProperty('javaVersion') ?: ext.modernJavaVersion).toString().toInteger()
def buildJavaLanguageVersion = JavaLanguageVersion.of(buildJavaMajorVersion)
def buildJavaVersion = JavaVersion.toVersion(buildJavaMajorVersion.toString())
java { java {
sourceCompatibility = JavaVersion.VERSION_25 sourceCompatibility = buildJavaVersion
targetCompatibility = JavaVersion.VERSION_25 targetCompatibility = buildJavaVersion
toolchain { toolchain {
languageVersion = JavaLanguageVersion.of(project.findProperty('javaVersion')?.toString() ?: '25') languageVersion = buildJavaLanguageVersion
} }
} }
@@ -171,10 +175,10 @@ subprojects {
apply plugin: 'jacoco' apply plugin: 'jacoco'
java { java {
sourceCompatibility = JavaVersion.VERSION_25 sourceCompatibility = buildJavaVersion
targetCompatibility = JavaVersion.VERSION_25 targetCompatibility = buildJavaVersion
toolchain { toolchain {
languageVersion = JavaLanguageVersion.of(25) languageVersion = buildJavaLanguageVersion
} }
} }
@@ -262,7 +266,7 @@ subprojects {
tasks.withType(JavaCompile).configureEach { tasks.withType(JavaCompile).configureEach {
options.encoding = "UTF-8" options.encoding = "UTF-8"
options.release = rootProject.ext.modernJavaVersion options.release = buildJavaMajorVersion
if (!project.hasProperty("noSpotless")) { if (!project.hasProperty("noSpotless")) {
dependsOn "spotlessApply" dependsOn "spotlessApply"
} }
@@ -657,10 +661,14 @@ tasks.register('compileRestartHelper', JavaCompile) {
source = fileTree(dir: 'scripts', include: 'RestartHelper.java') source = fileTree(dir: 'scripts', include: 'RestartHelper.java')
classpath = files() classpath = files()
destinationDirectory = layout.buildDirectory.dir("restart-helper-classes") destinationDirectory = layout.buildDirectory.dir("restart-helper-classes")
def restartMajorVersion = project.ext.modernJavaVersion def restartMajorVersion = buildJavaMajorVersion
def restartLanguageVersion = JavaLanguageVersion.of(restartMajorVersion)
def restartCompatibility = JavaVersion.toVersion(restartMajorVersion.toString()) def restartCompatibility = JavaVersion.toVersion(restartMajorVersion.toString())
sourceCompatibility = restartCompatibility sourceCompatibility = restartCompatibility
targetCompatibility = restartCompatibility targetCompatibility = restartCompatibility
javaCompiler = javaToolchains.compilerFor {
languageVersion = restartLanguageVersion
}
options.release.set(restartMajorVersion) options.release.set(restartMajorVersion)
} }