From 2319e11ff17af0d81eb80c6df09a37b4be5d12e0 Mon Sep 17 00:00:00 2001 From: strangepleasures Date: Thu, 12 Oct 2023 13:37:23 +0000 Subject: [PATCH] [KAPT] KT-62059 Disable incremental stub generation in K2 --- .../test/kotlin/org/jetbrains/kotlin/gradle/Kapt3IT.kt | 4 ++-- .../test/kotlin/org/jetbrains/kotlin/gradle/Kapt4IT.kt | 10 ++++++---- .../gradle/internal/kapt/KaptGenerateStubsTask.kt | 3 +++ 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/kotlin/org/jetbrains/kotlin/gradle/Kapt3IT.kt b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/kotlin/org/jetbrains/kotlin/gradle/Kapt3IT.kt index b0c09d30fb8..2b42a6b3562 100644 --- a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/kotlin/org/jetbrains/kotlin/gradle/Kapt3IT.kt +++ b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/kotlin/org/jetbrains/kotlin/gradle/Kapt3IT.kt @@ -351,13 +351,13 @@ open class Kapt3IT : Kapt3BaseIT() { @DisplayName("Kapt is working with incremental compilation") @GradleTest - fun testSimpleWithIC(gradleVersion: GradleVersion) { + open fun testSimpleWithIC(gradleVersion: GradleVersion) { doTestSimpleWithIC(gradleVersion) } @DisplayName("Kapt is working with incremental compilation, when kotlin.incremental.useClasspathSnapshot=true") @GradleTest - fun testSimpleWithIC_withClasspathSnapshot(gradleVersion: GradleVersion) { + open fun testSimpleWithIC_withClasspathSnapshot(gradleVersion: GradleVersion) { doTestSimpleWithIC(gradleVersion, useClasspathSnapshot = true) } diff --git a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/kotlin/org/jetbrains/kotlin/gradle/Kapt4IT.kt b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/kotlin/org/jetbrains/kotlin/gradle/Kapt4IT.kt index 08e1afb65ee..60157c5df94 100644 --- a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/kotlin/org/jetbrains/kotlin/gradle/Kapt4IT.kt +++ b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/kotlin/org/jetbrains/kotlin/gradle/Kapt4IT.kt @@ -21,10 +21,6 @@ class Kapt4IT : Kapt3IT() { forceKapt4() } - - @Disabled("Enable when KT-61845 is fixed") - override fun testKt18799(gradleVersion: GradleVersion) {} - @Disabled("Doesn't make sense in Kapt 4") override fun useGeneratedKotlinSourceK2(gradleVersion: GradleVersion) {} @@ -78,6 +74,12 @@ class Kapt4ClassLoadersCacheIT : Kapt3ClassLoadersCacheIT() { @Disabled("Doesn't work in 2.0. Neither with Kapt 3 nor with Kapt 4") override fun testMPPKaptPresence(gradleVersion: GradleVersion) {} + + @Disabled("Incremental compilation doesn't work in 2.0") + override fun testSimpleWithIC(gradleVersion: GradleVersion) {} + + @Disabled("Incremental compilation doesn't work in 2.0") + override fun testSimpleWithIC_withClasspathSnapshot(gradleVersion: GradleVersion) {} } fun TestProject.forceKapt4() { diff --git a/libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/gradle/internal/kapt/KaptGenerateStubsTask.kt b/libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/gradle/internal/kapt/KaptGenerateStubsTask.kt index 8e60e6d64fc..18f514c9256 100644 --- a/libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/gradle/internal/kapt/KaptGenerateStubsTask.kt +++ b/libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/gradle/internal/kapt/KaptGenerateStubsTask.kt @@ -152,4 +152,7 @@ abstract class KaptGenerateStubsTask @Inject constructor( args.freeArgs += (scriptSources.asFileTree.files + javaSources.files + sources.asFileTree.files).map { it.absolutePath } } } + + override fun isIncrementalCompilationEnabled(): Boolean = + super.isIncrementalCompilationEnabled() && !useK2Kapt.get() && ("-Xuse-kapt4" !in compilerOptions.freeCompilerArgs.get()) }