Move to JDK_X_Y variables

This commit is contained in:
Nikolay Krasko
2022-09-05 15:04:44 +02:00
committed by Space
parent 2df9203336
commit 1630386712
24 changed files with 71 additions and 52 deletions
+10 -1
View File
@@ -14,4 +14,13 @@ kotlin.build.gradlePlugin.version=0.0.38
# Please keep it in sync with root gradle.properties.
# It's currently needed for proper configuration cache work, the reason will be investigated later
org.gradle.java.installations.fromEnv=JDK_16,JDK_17,JDK_18,JDK_9,JDK_10,JDK_11,JDK_15,JDK_16_0,JDK_17_0
org.gradle.java.installations.fromEnv=\
JDK_1_6,JDK_16,\
JDK_1_7,JDK_17,\
JDK_1_8,JDK_18,\
JDK_9_0,JDK_9,\
JDK_10_0,JDK_10,\
JDK_11_0,JDK_11,\
JDK_15_0,JDK_15,\
JDK_16_0,\
JDK_17_0
+5 -5
View File
@@ -18,11 +18,11 @@ enum class JdkMajorVersion(
JDK_1_6(6, targetName = "1.6", overrideMajorVersion = 8),
JDK_1_7(7, targetName = "1.7", overrideMajorVersion = 8),
JDK_1_8(8, targetName = "1.8"),
JDK_9(9, overrideMajorVersion = 11),
JDK_10(10, mandatory = false, overrideMajorVersion = 11),
JDK_11(11, mandatory = false),
JDK_16(16, mandatory = false),
JDK_17(17, mandatory = false);
JDK_9_0(9, overrideMajorVersion = 11),
JDK_10_0(10, mandatory = false, overrideMajorVersion = 11),
JDK_11_0(11, mandatory = false),
JDK_16_0(16, mandatory = false),
JDK_17_0(17, mandatory = false);
fun isMandatory(): Boolean = mandatory
+3 -3
View File
@@ -21,9 +21,9 @@ fun Project.configureJava9Compilation(
configurations["java9CompileClasspath"].extendsFrom(configurations["compileClasspath"])
tasks.named("compileJava9Kotlin", KotlinCompile::class.java) {
configureTaskToolchain(JdkMajorVersion.JDK_9)
configureTaskToolchain(JdkMajorVersion.JDK_9_0)
@Suppress("DEPRECATION")
kotlinOptions.jvmTarget = JdkMajorVersion.JDK_9.targetName
kotlinOptions.jvmTarget = JdkMajorVersion.JDK_9_0.targetName
}
tasks.named("compileJava9Java", JavaCompile::class.java) {
@@ -31,7 +31,7 @@ fun Project.configureJava9Compilation(
targetCompatibility = JavaVersion.VERSION_1_9.toString()
sourceCompatibility = JavaVersion.VERSION_1_9.toString()
configureTaskToolchain(JdkMajorVersion.JDK_9)
configureTaskToolchain(JdkMajorVersion.JDK_9_0)
// module-info.java should be in java9 source set by convention
val java9SourceSet = sourceSets["java9"].java
+4 -1
View File
@@ -279,7 +279,10 @@ private fun String.toMaybeVersionedJarRegex(): Regex {
return Regex(if (hasJarExtension) escaped else "$escaped(-\\d.*)?\\.jar") // TODO: consider more precise version part of the regex
}
fun Project.firstFromJavaHomeThatExists(vararg paths: String, jdkHome: File = File(this.property("JDK_18") as String)): File? =
fun Project.firstFromJavaHomeThatExists(
vararg paths: String,
jdkHome: File = File((this.property("JDK_1_8") ?: this.property("JDK_18") ?: error("Can't find JDK_1_8 property")) as String)
): File? =
paths.map { File(jdkHome, it) }.firstOrNull { it.exists() }.also {
if (it == null)
logger.warn("Cannot find file by paths: ${paths.toList()} in $jdkHome")