feat(build): automatically handle Compose Compiler compatibility override
This commit is contained in:
parent
61ae1d4194
commit
214140d7d1
1 changed files with 19 additions and 0 deletions
|
@ -8,10 +8,15 @@ package app.passwordstore.gradle
|
||||||
import app.passwordstore.gradle.KotlinCommonPlugin.Companion.JVM_TOOLCHAIN_ACTION
|
import app.passwordstore.gradle.KotlinCommonPlugin.Companion.JVM_TOOLCHAIN_ACTION
|
||||||
import org.gradle.api.Plugin
|
import org.gradle.api.Plugin
|
||||||
import org.gradle.api.Project
|
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.apply
|
||||||
import org.gradle.kotlin.dsl.getByType
|
import org.gradle.kotlin.dsl.getByType
|
||||||
|
import org.gradle.kotlin.dsl.withType
|
||||||
import org.jetbrains.kotlin.gradle.dsl.KotlinProjectExtension
|
import org.jetbrains.kotlin.gradle.dsl.KotlinProjectExtension
|
||||||
import org.jetbrains.kotlin.gradle.plugin.KotlinAndroidPluginWrapper
|
import org.jetbrains.kotlin.gradle.plugin.KotlinAndroidPluginWrapper
|
||||||
|
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
|
||||||
|
|
||||||
@Suppress("Unused")
|
@Suppress("Unused")
|
||||||
class KotlinAndroidPlugin : Plugin<Project> {
|
class KotlinAndroidPlugin : Plugin<Project> {
|
||||||
|
@ -22,5 +27,19 @@ class KotlinAndroidPlugin : Plugin<Project> {
|
||||||
apply(KotlinCommonPlugin::class)
|
apply(KotlinCommonPlugin::class)
|
||||||
}
|
}
|
||||||
project.extensions.getByType<KotlinProjectExtension>().jvmToolchain(JVM_TOOLCHAIN_ACTION)
|
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()
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue