diff options
author | Harsh Shandilya <me@msfjarvis.dev> | 2023-07-06 12:23:23 +0530 |
---|---|---|
committer | Harsh Shandilya <me@msfjarvis.dev> | 2023-07-06 12:36:55 +0530 |
commit | 214140d7d14b540a3dff986b34ef17b99701cd60 (patch) | |
tree | ae983491ecc8bfc890bfd0c9bfd7b45eea05355c /build-logic | |
parent | 61ae1d41943efb9a79c1de3016ca5a3ef071be8f (diff) |
feat(build): automatically handle Compose Compiler compatibility override
Diffstat (limited to 'build-logic')
-rw-r--r-- | build-logic/src/main/kotlin/app/passwordstore/gradle/KotlinAndroidPlugin.kt | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/build-logic/src/main/kotlin/app/passwordstore/gradle/KotlinAndroidPlugin.kt b/build-logic/src/main/kotlin/app/passwordstore/gradle/KotlinAndroidPlugin.kt index 46a5eb30..9e1641f3 100644 --- a/build-logic/src/main/kotlin/app/passwordstore/gradle/KotlinAndroidPlugin.kt +++ b/build-logic/src/main/kotlin/app/passwordstore/gradle/KotlinAndroidPlugin.kt @@ -8,10 +8,15 @@ package app.passwordstore.gradle import app.passwordstore.gradle.KotlinCommonPlugin.Companion.JVM_TOOLCHAIN_ACTION import org.gradle.api.Plugin import org.gradle.api.Project +import org.gradle.api.artifacts.VersionCatalog +import org.gradle.api.artifacts.VersionCatalogsExtension +import org.gradle.api.artifacts.VersionConstraint import org.gradle.kotlin.dsl.apply import org.gradle.kotlin.dsl.getByType +import org.gradle.kotlin.dsl.withType import org.jetbrains.kotlin.gradle.dsl.KotlinProjectExtension import org.jetbrains.kotlin.gradle.plugin.KotlinAndroidPluginWrapper +import org.jetbrains.kotlin.gradle.tasks.KotlinCompile @Suppress("Unused") class KotlinAndroidPlugin : Plugin<Project> { @@ -22,5 +27,19 @@ class KotlinAndroidPlugin : Plugin<Project> { apply(KotlinCommonPlugin::class) } project.extensions.getByType<KotlinProjectExtension>().jvmToolchain(JVM_TOOLCHAIN_ACTION) + val catalog = project.extensions.getByType<VersionCatalogsExtension>() + val libs = catalog.named("libs") + if (libs.getVersion("composeCompiler").contains("-dev")) { + val kotlinVersion = libs.getVersion("kotlin") + project.tasks.withType<KotlinCompile>().configureEach { + compilerOptions.freeCompilerArgs.addAll( + "-P", + "plugin:androidx.compose.compiler.plugins.kotlin:suppressKotlinVersionCompatibilityCheck=$kotlinVersion", + ) + } + } } + + private fun VersionCatalog.getVersion(key: String) = + findVersion(key).map(VersionConstraint::toString).get() } |