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
@@ -5,7 +5,6 @@ import org.gradle.kotlin.dsl.support.serviceOf
description = "Shaded Maven dependencies resolver"
val JDK_18: String by rootProject.extra
val jarBaseName = property("archivesBaseName") as String
val embedded by configurations
+3 -3
View File
@@ -103,7 +103,7 @@ task testJdk6Tests(type: Test) { thisTask ->
}
}
[JdkMajorVersion.JDK_9, JdkMajorVersion.JDK_10, JdkMajorVersion.JDK_11].forEach { jvmVersion ->
[JdkMajorVersion.JDK_9_0, JdkMajorVersion.JDK_10_0, JdkMajorVersion.JDK_11_0].forEach { jvmVersion ->
check.dependsOn(tasks.register("jdk${jvmVersion.majorVersion}Test", Test) { thisTask ->
group = "verification"
thisTask.javaLauncher.set(JvmToolchain.getToolchainLauncherFor(project, jvmVersion))
@@ -111,7 +111,7 @@ task testJdk6Tests(type: Test) { thisTask ->
}
compileModuleTestKotlin {
kotlinJavaToolchain.toolchain.use(JvmToolchain.getToolchainLauncherFor(project, JdkMajorVersion.JDK_9))
kotlinJavaToolchain.toolchain.use(JvmToolchain.getToolchainLauncherFor(project, JdkMajorVersion.JDK_9_0))
}
check.dependsOn(tasks.register("moduleInfoTest", Test) {test ->
@@ -119,7 +119,7 @@ check.dependsOn(tasks.register("moduleInfoTest", Test) {test ->
test.group = "verification"
test.testClassesDirs = sourceSets.moduleTest.output.classesDirs
test.classpath = files(sourceSets.moduleTest.runtimeClasspath, tasks.jar)
test.javaLauncher.set(JvmToolchain.getToolchainLauncherFor(project, JdkMajorVersion.JDK_9))
test.javaLauncher.set(JvmToolchain.getToolchainLauncherFor(project, JdkMajorVersion.JDK_9_0))
doFirst {
test.systemProperty("stdlibJars", test.classpath.filter { it.name.contains('kotlin-stdlib') }.join(File.pathSeparator))
}
@@ -99,7 +99,7 @@ private interface TypeImpl : Type {
// This is a copy of [Type.getTypeName] which is present on JDK 8+.
@Suppress(
"VIRTUAL_MEMBER_HIDDEN", "NON_JVM_DEFAULT_OVERRIDES_JAVA_DEFAULT"
) // This is needed for cases when environment variable JDK_16 points to JDK 8+.
) // This is needed for cases when environment variable JDK_1_6 points to JDK 8+.
fun getTypeName(): String
}
@@ -126,7 +126,7 @@ private class TypeVariableImpl(private val typeParameter: KTypeParameter) : Type
override fun toString(): String = getTypeName()
// [TypeVariable] extends [AnnotatedElement] starting from JDK 8. The following are copies of methods from there.
// Suppression of VIRTUAL_MEMBER_HIDDEN is needed for cases when environment variable JDK_16 points to JDK 8+.
// Suppression of VIRTUAL_MEMBER_HIDDEN is needed for cases when environment variable JDK_1_6 points to JDK 8+.
@Suppress("VIRTUAL_MEMBER_HIDDEN", "UNUSED_PARAMETER")
fun <T : Annotation> getAnnotation(annotationClass: Class<T>): T? = null
@@ -329,10 +329,10 @@ tasks.withType<Test> {
}
val jdk8Provider = project.getToolchainLauncherFor(JdkMajorVersion.JDK_1_8).map { it.metadata.installationPath.asFile.absolutePath }
val jdk9Provider = project.getToolchainLauncherFor(JdkMajorVersion.JDK_9).map { it.metadata.installationPath.asFile.absolutePath }
val jdk10Provider = project.getToolchainLauncherFor(JdkMajorVersion.JDK_10).map { it.metadata.installationPath.asFile.absolutePath }
val jdk11Provider = project.getToolchainLauncherFor(JdkMajorVersion.JDK_11).map { it.metadata.installationPath.asFile.absolutePath }
val jdk16Provider = project.getToolchainLauncherFor(JdkMajorVersion.JDK_16).map { it.metadata.installationPath.asFile.absolutePath }
val jdk9Provider = project.getToolchainLauncherFor(JdkMajorVersion.JDK_9_0).map { it.metadata.installationPath.asFile.absolutePath }
val jdk10Provider = project.getToolchainLauncherFor(JdkMajorVersion.JDK_10_0).map { it.metadata.installationPath.asFile.absolutePath }
val jdk11Provider = project.getToolchainLauncherFor(JdkMajorVersion.JDK_11_0).map { it.metadata.installationPath.asFile.absolutePath }
val jdk16Provider = project.getToolchainLauncherFor(JdkMajorVersion.JDK_16_0).map { it.metadata.installationPath.asFile.absolutePath }
val mavenLocalRepo = project.providers.systemProperty("maven.repo.local").forUseAtConfigurationTime().orNull
// Query required JDKs paths only on execution phase to avoid triggering auto-download on project configuration phase