feat(build): apply Android Lint plugin to JVM modules

This commit is contained in:
Harsh Shandilya 2023-04-20 16:31:32 +05:30
parent 06528e7504
commit 237a06f1cf
No known key found for this signature in database
2 changed files with 12 additions and 4 deletions

View file

@ -1,14 +1,18 @@
/*
* Copyright © 2022 Harsh Shandilya.
* Copyright © 2022-2023 Harsh Shandilya.
* Use of this source code is governed by an MIT-style
* license that can be found in the LICENSE file or at
* https://opensource.org/licenses/MIT.
*/
package dev.msfjarvis.claw.gradle
import com.android.build.api.dsl.Lint
import com.android.build.gradle.LintPlugin
import dev.msfjarvis.claw.gradle.LintConfig.configureLint
import org.gradle.api.Plugin
import org.gradle.api.Project
import org.gradle.kotlin.dsl.apply
import org.gradle.kotlin.dsl.findByType
import org.jetbrains.kotlin.gradle.plugin.KotlinPluginWrapper
@Suppress("Unused")
@ -16,5 +20,7 @@ class KotlinJvmPlugin : Plugin<Project> {
override fun apply(project: Project) {
project.pluginManager.apply(KotlinPluginWrapper::class)
project.pluginManager.apply(KotlinCommonPlugin::class)
project.pluginManager.apply(LintPlugin::class)
project.extensions.findByType<Lint>()?.configureLint(project, isJVM = true)
}
}

View file

@ -10,7 +10,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
@ -24,8 +24,10 @@ object LintConfig {
xmlReport = false
htmlReport = true
sarifReport = true
if (!isJVM) {
enable += "ComposeM2Api"
error += "ComposeM2Api"
}
baseline = project.file("lint-baseline.xml")
}
}