From 5659ad9863f7ce47962668a473fd29c79d9c710e Mon Sep 17 00:00:00 2001 From: Harsh Shandilya Date: Thu, 27 Apr 2023 14:43:47 +0530 Subject: feat(build): add Slack's Compose Lints --- .../src/main/kotlin/app/passwordstore/gradle/AndroidCommon.kt | 8 ++++++++ .../src/main/kotlin/app/passwordstore/gradle/KotlinJVMLibrary.kt | 2 +- .../src/main/kotlin/app/passwordstore/gradle/LintConfig.kt | 6 +++++- 3 files changed, 14 insertions(+), 2 deletions(-) (limited to 'build-logic/src/main/kotlin') diff --git a/build-logic/src/main/kotlin/app/passwordstore/gradle/AndroidCommon.kt b/build-logic/src/main/kotlin/app/passwordstore/gradle/AndroidCommon.kt index 04a2dc7a..c337d9d5 100644 --- a/build-logic/src/main/kotlin/app/passwordstore/gradle/AndroidCommon.kt +++ b/build-logic/src/main/kotlin/app/passwordstore/gradle/AndroidCommon.kt @@ -7,9 +7,11 @@ import com.android.build.api.dsl.LibraryExtension import com.android.build.gradle.TestedExtension import org.gradle.api.JavaVersion import org.gradle.api.Project +import org.gradle.api.artifacts.VersionCatalogsExtension import org.gradle.api.tasks.testing.Test import org.gradle.kotlin.dsl.configure import org.gradle.kotlin.dsl.findByType +import org.gradle.kotlin.dsl.getByType import org.gradle.kotlin.dsl.withType object AndroidCommon { @@ -56,5 +58,11 @@ object AndroidCommon { } project.extensions.findByType()?.run { lint.configureLint(project) } project.extensions.findByType()?.run { lint.configureLint(project) } + val catalog = project.extensions.getByType() + val libs = catalog.named("libs") + project.dependencies.addProvider( + "lintChecks", + libs.findLibrary("thirdparty-compose-lints").get() + ) } } diff --git a/build-logic/src/main/kotlin/app/passwordstore/gradle/KotlinJVMLibrary.kt b/build-logic/src/main/kotlin/app/passwordstore/gradle/KotlinJVMLibrary.kt index 253c7aed..c5cf84a0 100644 --- a/build-logic/src/main/kotlin/app/passwordstore/gradle/KotlinJVMLibrary.kt +++ b/build-logic/src/main/kotlin/app/passwordstore/gradle/KotlinJVMLibrary.kt @@ -23,6 +23,6 @@ class KotlinJVMLibrary : Plugin { apply(LintPlugin::class) apply(KotlinCommonPlugin::class) } - project.extensions.configure { configureLint(project) } + project.extensions.configure { configureLint(project, isJVM = true) } } } diff --git a/build-logic/src/main/kotlin/app/passwordstore/gradle/LintConfig.kt b/build-logic/src/main/kotlin/app/passwordstore/gradle/LintConfig.kt index 41bb781f..de63c580 100644 --- a/build-logic/src/main/kotlin/app/passwordstore/gradle/LintConfig.kt +++ b/build-logic/src/main/kotlin/app/passwordstore/gradle/LintConfig.kt @@ -4,7 +4,7 @@ import com.android.build.api.dsl.Lint import org.gradle.api.Project object LintConfig { - fun Lint.configureLint(project: Project) { + fun Lint.configureLint(project: Project, isJVM: Boolean = false) { quiet = project.providers.environmentVariable("CI").isPresent abortOnError = true checkReleaseBuilds = true @@ -28,6 +28,10 @@ object LintConfig { disable += "TypographyQuotes" // False-positives abound due to use of ViewBinding disable += "UnusedIds" + if (!isJVM) { + enable += "ComposeM2Api" + error += "ComposeM2Api" + } baseline = project.file("lint-baseline.xml") } } -- cgit v1.2.3