https://kotlinlang.org logo
Title
f

Francesc

02/11/2023, 9:31 PM
I'm writing a precompiled plugin to apply the Lint rules to the modules on my app. On Groovy you'd call
dependencies {
    lintChecks("com.slack.lint.compose:compose-lint-checks:1.0.0")
}
in the
android
block but in Kotlin this doesn't work, it complains that I need to pass a
Closure
. How can I call
lintChecks
in Kotlin? I'm pasting the whole code in the thread
import com.android.build.gradle.LibraryExtension
import org.gradle.api.Action
import org.gradle.api.Project
import org.gradle.api.plugins.ExtensionAware

internal fun Project.configureAndroidLint(
    commonExtension: LibraryExtension,
) {
    commonExtension.apply {
        androidOptions {
            dependencies {
                lintChecks("com.slack.lint.compose:compose-lint-checks:1.0.0")
            }
            lint {
                quiet = false
                abortOnError = true
                checkDependencies = true
                ignoreTestSources = true
                warningsAsErrors = true
                lintConfig = file(rootDir.path + "/testing/lint/lint-config.xml")
                htmlOutput = file("${project.buildDir}/reports/lint/lint.html")
            }
        }
    }
}

private fun Project.androidOptions(block: Action<LibraryExtension>): Unit =
    (this as ExtensionAware).extensions.configure("android", block)
m

MR3Y

02/11/2023, 10:57 PM
I think you need to add it without using
lintChecks
type-safe accessor:
dependencies.add("lintChecks", "com.slack.lint.compose:compose-lint-checks:1.0.0")
f

Francesc

02/12/2023, 1:41 AM
that worked, thanks!
b

Big Chungus

02/12/2023, 1:14 PM
Also "lintCheck"("coordinates") is available (works via add("configuration","notation")
f

Francesc

02/12/2023, 6:31 PM
how would you use
lintCheck
? When I tried it didn't resolve