aboutsummaryrefslogtreecommitdiff
path: root/build-logic
diff options
context:
space:
mode:
authorHarsh Shandilya <me@msfjarvis.dev>2023-07-07 12:08:50 +0530
committerHarsh Shandilya <me@msfjarvis.dev>2023-07-07 12:08:50 +0530
commit884dd5dee9d72188416cda535f9731047f4ae96b (patch)
tree004f4412594f0df2878b6c072e9321c29cb425ba /build-logic
parentaab513060bf5e5493ec0d58fe5083133f07ef69c (diff)
fix(build): only suppress compat check for Compose Compiler when required
Diffstat (limited to 'build-logic')
-rw-r--r--build-logic/src/main/kotlin/app/passwordstore/gradle/KotlinAndroidPlugin.kt25
1 files changed, 18 insertions, 7 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 9e1641f3..a80a5807 100644
--- a/build-logic/src/main/kotlin/app/passwordstore/gradle/KotlinAndroidPlugin.kt
+++ b/build-logic/src/main/kotlin/app/passwordstore/gradle/KotlinAndroidPlugin.kt
@@ -29,17 +29,28 @@ class KotlinAndroidPlugin : Plugin<Project> {
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",
- )
+ val composeCompilerVersion = libs.getVersion("composeCompiler")
+ val kotlinVersion = libs.getVersion("kotlin")
+ val matches = COMPOSE_COMPILER_VERSION_REGEX.find(composeCompilerVersion)
+
+ if (matches != null) {
+ val (compilerKotlinVersion) = matches.destructured
+ if (compilerKotlinVersion != kotlinVersion) {
+ 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()
+
+ private companion object {
+ // Matches against 1.5.0-dev-k1.9.0-6a60475e07f
+ val COMPOSE_COMPILER_VERSION_REGEX = "\\d.\\d.\\d-dev-k(\\d.\\d.\\d)-[a-z0-9]+".toRegex()
+ }
}