KAPT3: Use another class in com.sun.tools.javac.main
Instead of CommandLine use Option, since CommandLine was moved or removed from JDK 21. #KT-60507 Fixed
This commit is contained in:
committed by
Space Team
parent
62effc49fa
commit
6c13250a08
@@ -1,4 +1,5 @@
|
|||||||
import org.gradle.api.tasks.testing.logging.TestExceptionFormat
|
import org.gradle.api.tasks.testing.logging.TestExceptionFormat
|
||||||
|
import org.gradle.jvm.toolchain.internal.NoToolchainAvailableException
|
||||||
import org.jetbrains.kotlin.pill.PillExtension
|
import org.jetbrains.kotlin.pill.PillExtension
|
||||||
|
|
||||||
plugins {
|
plugins {
|
||||||
@@ -346,6 +347,12 @@ tasks.withType<Test> {
|
|||||||
systemProperty("jdk11Home", jdk11Provider.get())
|
systemProperty("jdk11Home", jdk11Provider.get())
|
||||||
systemProperty("jdk16Home", jdk16Provider.get())
|
systemProperty("jdk16Home", jdk16Provider.get())
|
||||||
systemProperty("jdk17Home", jdk17Provider.get())
|
systemProperty("jdk17Home", jdk17Provider.get())
|
||||||
|
// jdk21Provider.isPresent throws NoToolchainAvailableException, so, we have to check for the exception
|
||||||
|
// Storing jdk21Provider in a field leads to "Configuration cache state could not be cached" error,
|
||||||
|
// since it tries to resolve the toolchain as well.
|
||||||
|
try {
|
||||||
|
systemProperty("jdk21Home", project.getToolchainJdkHomeFor(JdkMajorVersion.JDK_21_0).get())
|
||||||
|
} catch (_: NoToolchainAvailableException) {}
|
||||||
if (mavenLocalRepo != null) {
|
if (mavenLocalRepo != null) {
|
||||||
systemProperty("maven.repo.local", mavenLocalRepo)
|
systemProperty("maven.repo.local", mavenLocalRepo)
|
||||||
}
|
}
|
||||||
|
|||||||
+30
@@ -180,6 +180,36 @@ open class Kapt3IT : Kapt3BaseIT() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: Remove as JDK 21 is supported on Java Toolchains
|
||||||
|
@DisplayName("Kapt is working with JDK 21")
|
||||||
|
@GradleTest
|
||||||
|
@GradleTestVersions(minVersion = TestVersions.Gradle.G_7_3)
|
||||||
|
@EnableOnJdk21
|
||||||
|
fun doTestSimpleWithJdk21(
|
||||||
|
gradleVersion: GradleVersion
|
||||||
|
) {
|
||||||
|
project(
|
||||||
|
"simple".withPrefix,
|
||||||
|
gradleVersion
|
||||||
|
) {
|
||||||
|
//language=Groovy
|
||||||
|
buildGradle.appendText(
|
||||||
|
"""
|
||||||
|
|
|
||||||
|
|kotlin {
|
||||||
|
| jvmToolchain(21)
|
||||||
|
|}
|
||||||
|
""".trimMargin()
|
||||||
|
)
|
||||||
|
|
||||||
|
build("assemble") {
|
||||||
|
assertTasksExecuted(":kaptGenerateStubsKotlin", ":kaptKotlin")
|
||||||
|
// Check added because of https://youtrack.jetbrains.com/issue/KT-33056.
|
||||||
|
assertOutputDoesNotContain("javaslang.match.PatternsProcessor")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@DisplayName("KT-48402: Kapt worker classpath is using JRE classes from toolchain")
|
@DisplayName("KT-48402: Kapt worker classpath is using JRE classes from toolchain")
|
||||||
@JdkVersions(versions = [JavaVersion.VERSION_16])
|
@JdkVersions(versions = [JavaVersion.VERSION_16])
|
||||||
@GradleWithJdkTest
|
@GradleWithJdkTest
|
||||||
|
|||||||
+25
@@ -0,0 +1,25 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2010-2023 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||||
|
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.jetbrains.kotlin.gradle.testbase
|
||||||
|
|
||||||
|
import org.junit.jupiter.api.extension.ConditionEvaluationResult
|
||||||
|
import org.junit.jupiter.api.extension.ExecutionCondition
|
||||||
|
import org.junit.jupiter.api.extension.ExtendWith
|
||||||
|
import org.junit.jupiter.api.extension.ExtensionContext
|
||||||
|
|
||||||
|
class EnableOnJdk21Condition : ExecutionCondition {
|
||||||
|
override fun evaluateExecutionCondition(context: ExtensionContext?): ConditionEvaluationResult =
|
||||||
|
if (System.getProperty("jdk21Home") == null) {
|
||||||
|
ConditionEvaluationResult.disabled("No JDK 21 Found")
|
||||||
|
} else {
|
||||||
|
ConditionEvaluationResult.enabled("JDK 21 Found")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Target(AnnotationTarget.FUNCTION)
|
||||||
|
@Retention(AnnotationRetention.RUNTIME)
|
||||||
|
@ExtendWith(EnableOnJdk21Condition::class)
|
||||||
|
annotation class EnableOnJdk21
|
||||||
+1
-1
@@ -15,7 +15,7 @@ val REQUIRED_PACKAGES_TO_TEST_CLASSES = mapOf(
|
|||||||
"com.sun.tools.javac.util" to "Context",
|
"com.sun.tools.javac.util" to "Context",
|
||||||
"com.sun.tools.javac.file" to "CacheFSInfo",
|
"com.sun.tools.javac.file" to "CacheFSInfo",
|
||||||
"com.sun.tools.javac.tree" to "TreeTranslator",
|
"com.sun.tools.javac.tree" to "TreeTranslator",
|
||||||
"com.sun.tools.javac.main" to "CommandLine",
|
"com.sun.tools.javac.main" to "Option",
|
||||||
"com.sun.tools.javac.jvm" to "ClassFile",
|
"com.sun.tools.javac.jvm" to "ClassFile",
|
||||||
"com.sun.tools.javac.parser" to "Tokens\$TokenKind",
|
"com.sun.tools.javac.parser" to "Tokens\$TokenKind",
|
||||||
"com.sun.tools.javac.code" to "Source",
|
"com.sun.tools.javac.code" to "Source",
|
||||||
|
|||||||
Reference in New Issue
Block a user