Skip to content

Commit

Permalink
Don't configure KspTask in KotlinCompile tasks
Browse files Browse the repository at this point in the history
Similar to stub gen, we don't actually want to configure these even though they extend kotlincompile because KSP applies their own mappings
  • Loading branch information
ZacSweers committed Nov 20, 2023
1 parent 042e261 commit afc442a
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions slack-plugin/src/main/kotlin/slack/gradle/util/kgpUtil.kt
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
*/
package slack.gradle.util

import com.google.devtools.ksp.gradle.KspTask
import org.gradle.api.tasks.TaskContainer
import org.jetbrains.kotlin.gradle.internal.KaptGenerateStubsTask
import org.jetbrains.kotlin.gradle.tasks.KotlinCompilationTask
Expand All @@ -31,12 +32,14 @@ import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
*/
internal fun TaskContainer.configureKotlinCompilationTask(
includeKaptGenerateStubsTask: Boolean = false,
includeKspTask: Boolean = false,
action: KotlinCompilationTask<*>.() -> Unit
) {
withType(KotlinCompilationTask::class.java)
// Kapt stub gen is a special case because KGP sets it up to copy compiler args from the
// standard kotlin compilation, which can lead to duplicates. SOOOO we skip configuration of
// it here. Callers to this _can_ opt in to including it, but they must be explicit.
.matching { includeKaptGenerateStubsTask || it !is KaptGenerateStubsTask }
.matching { includeKspTask || it !is KspTask }
.configureEach { action() }
}

0 comments on commit afc442a

Please sign in to comment.