From bfa9de119be6a67793647990ba767e2a18d7809b Mon Sep 17 00:00:00 2001 From: Ting-Yuan Huang Date: Fri, 1 Nov 2024 15:30:04 -0700 Subject: [PATCH] Disable KSP2 tasks with corresponding compilation If the corresponding Kotlin native compilation is disabled, KSP should be disabled as well. This aligns with KSP1's behavior. --- .../main/kotlin/com/google/devtools/ksp/gradle/KspAATask.kt | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/gradle-plugin/src/main/kotlin/com/google/devtools/ksp/gradle/KspAATask.kt b/gradle-plugin/src/main/kotlin/com/google/devtools/ksp/gradle/KspAATask.kt index cc2967fa58..17d8cabfff 100644 --- a/gradle-plugin/src/main/kotlin/com/google/devtools/ksp/gradle/KspAATask.kt +++ b/gradle-plugin/src/main/kotlin/com/google/devtools/ksp/gradle/KspAATask.kt @@ -43,6 +43,7 @@ import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinJvmAndroidCompilation import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinNativeCompilation import org.jetbrains.kotlin.gradle.tasks.AbstractKotlinCompileTool import org.jetbrains.kotlin.gradle.tasks.KotlinNativeCompile +import org.jetbrains.kotlin.konan.target.HostManager import java.io.ByteArrayOutputStream import java.io.File import java.io.ObjectOutputStream @@ -269,6 +270,11 @@ abstract class KspAATask @Inject constructor( val konanTargetName = kotlinCompilation.target.konanTarget.name cfg.konanTargetName.value(konanTargetName) cfg.konanHome.value((kotlinCompileProvider.get() as KotlinNativeCompile).konanHome) + kspAATask.onlyIf { + HostManager().enabled.any { + it.name == konanTargetName + } + } } // TODO: pass targets of common