KT-57598 Run Kapt with K1 even when the compiler is run with K2
This commit is contained in:
committed by
Space Team
parent
cb4c41a5ca
commit
58143a2006
+59
@@ -18,6 +18,7 @@ package org.jetbrains.kotlin.gradle
|
||||
|
||||
import org.gradle.api.JavaVersion
|
||||
import org.gradle.api.logging.LogLevel
|
||||
import org.gradle.api.logging.configuration.WarningMode
|
||||
import org.gradle.testkit.runner.BuildResult
|
||||
import org.gradle.util.GradleVersion
|
||||
import org.jetbrains.kotlin.gradle.tasks.USING_JVM_INCREMENTAL_COMPILATION_MESSAGE
|
||||
@@ -1121,4 +1122,62 @@ open class Kapt3IT : Kapt3BaseIT() {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@DisplayName("Kapt runs in fallback mode with useK2 = true")
|
||||
@GradleTest
|
||||
internal fun fallBackModeWithUseK2(gradleVersion: GradleVersion) {
|
||||
project("simple".withPrefix, gradleVersion) {
|
||||
buildGradle.appendText(
|
||||
"""
|
||||
|tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).configureEach {
|
||||
| compilerOptions {
|
||||
| freeCompilerArgs.addAll([
|
||||
| "-Xuse-fir-ic",
|
||||
| "-Xuse-fir-lt"
|
||||
| ])
|
||||
| }
|
||||
| kotlinOptions {
|
||||
| useK2 = true
|
||||
| }
|
||||
|}
|
||||
|
|
||||
|compileKotlin.kotlinOptions.allWarningsAsErrors = false
|
||||
""".trimMargin()
|
||||
)
|
||||
build("build") {
|
||||
assertKaptSuccessful()
|
||||
assertTasksExecuted(":kaptGenerateStubsKotlin", ":kaptKotlin", ":compileKotlin")
|
||||
assertOutputContains("Falling back to 1.9.")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@DisplayName("Kapt runs in fallback mode with languageVersion = 2.0")
|
||||
@GradleTest
|
||||
internal fun fallBackModeWithLanguageVersion2_0(gradleVersion: GradleVersion) {
|
||||
project("simple".withPrefix, gradleVersion) {
|
||||
buildGradle.appendText(
|
||||
"""
|
||||
|tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).configureEach {
|
||||
| compilerOptions {
|
||||
| freeCompilerArgs.addAll([
|
||||
| "-Xuse-fir-ic",
|
||||
| "-Xuse-fir-lt"
|
||||
| ])
|
||||
| }
|
||||
| kotlinOptions {
|
||||
| languageVersion = "2.0"
|
||||
| }
|
||||
|}
|
||||
|
|
||||
|compileKotlin.kotlinOptions.allWarningsAsErrors = false
|
||||
""".trimMargin()
|
||||
)
|
||||
build("build") {
|
||||
assertKaptSuccessful()
|
||||
assertTasksExecuted(":kaptGenerateStubsKotlin", ":kaptKotlin", ":compileKotlin")
|
||||
assertOutputContains("Falling back to 1.9.")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user