diff --git a/slack-plugin/src/main/kotlin/slack/gradle/SlackProperties.kt b/slack-plugin/src/main/kotlin/slack/gradle/SlackProperties.kt index 99d9f6801..ae6463d5f 100644 --- a/slack-plugin/src/main/kotlin/slack/gradle/SlackProperties.kt +++ b/slack-plugin/src/main/kotlin/slack/gradle/SlackProperties.kt @@ -19,6 +19,7 @@ import java.io.File import java.util.Locale import org.gradle.api.Project import org.gradle.api.provider.Provider +import org.jetbrains.kotlin.gradle.dsl.KotlinVersion import slack.gradle.anvil.AnvilMode import slack.gradle.artifacts.SgpArtifact import slack.gradle.util.PropertyResolver @@ -618,6 +619,13 @@ internal constructor( AnvilMode.valueOf(it.uppercase(Locale.US)) } + /** Overrides the kotlin language version if present. */ + public val kaptLanguageVersion: Provider + get() = + resolver.optionalStringProvider("sgp.kapt.languageVersion").map { + KotlinVersion.fromVersion(it) + } + /** Defines a required vendor for JDK toolchains. */ public val jvmVendor: Provider get() = diff --git a/slack-plugin/src/main/kotlin/slack/gradle/kgp/KgpTasks.kt b/slack-plugin/src/main/kotlin/slack/gradle/kgp/KgpTasks.kt index 3cff933ea..ae8527791 100644 --- a/slack-plugin/src/main/kotlin/slack/gradle/kgp/KgpTasks.kt +++ b/slack-plugin/src/main/kotlin/slack/gradle/kgp/KgpTasks.kt @@ -68,12 +68,28 @@ internal object KgpTasks { val isKaptGenerateStubsTask = this is KaptGenerateStubsTask compilerOptions { - progressiveMode.set(slackProperties.kotlinProgressive) + if (isKaptGenerateStubsTask && slackProperties.kaptLanguageVersion.isPresent) { + val zipped = + slackProperties.kotlinProgressive.zip(slackProperties.kaptLanguageVersion) { + progressive, + kaptLanguageVersion -> + if (kaptLanguageVersion != KotlinVersion.DEFAULT) { + false + } else { + progressive + } + } + progressiveMode.set(zipped) + } else { + progressiveMode.set(slackProperties.kotlinProgressive) + } optIn.addAll(slackProperties.kotlinOptIn) if (slackProperties.kotlinLanguageVersionOverride.isPresent) { languageVersion.set( slackProperties.kotlinLanguageVersionOverride.map(KotlinVersion::fromVersion) ) + } else if (isKaptGenerateStubsTask && slackProperties.kaptLanguageVersion.isPresent) { + languageVersion.set(slackProperties.kaptLanguageVersion) } if ( !slackProperties.allowWarnings &&