Skip to content

Commit

Permalink
Add a kapt language version override (#920)
Browse files Browse the repository at this point in the history
This allows us to force it to a lower version if needed for K2 testing

<!--
  ⬆ Put your description above this! ⬆

  Please be descriptive and detailed.
  
Please read our [Contributing
Guidelines](https://github.com/tinyspeck/slack-gradle-plugin/blob/main/.github/CONTRIBUTING.md)
and [Code of Conduct](https://slackhq.github.io/code-of-conduct).

Don't worry about deleting this, it's not visible in the PR!
-->
  • Loading branch information
ZacSweers authored Aug 12, 2024
1 parent 80a8d52 commit 847022e
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
8 changes: 8 additions & 0 deletions slack-plugin/src/main/kotlin/slack/gradle/SlackProperties.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -618,6 +619,13 @@ internal constructor(
AnvilMode.valueOf(it.uppercase(Locale.US))
}

/** Overrides the kotlin language version if present. */
public val kaptLanguageVersion: Provider<KotlinVersion>
get() =
resolver.optionalStringProvider("sgp.kapt.languageVersion").map {
KotlinVersion.fromVersion(it)
}

/** Defines a required vendor for JDK toolchains. */
public val jvmVendor: Provider<String>
get() =
Expand Down
18 changes: 17 additions & 1 deletion slack-plugin/src/main/kotlin/slack/gradle/kgp/KgpTasks.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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 &&
Expand Down

0 comments on commit 847022e

Please sign in to comment.