jeremymailen / kotlinter-gradle

Painless, fast ktlint plugin for Gradle
Apache License 2.0
597 stars 50 forks source link

kotliner configuration issue with using "subproject" in Kotlin DSL / Gradle #355

Closed Eightyplus closed 10 months ago

Eightyplus commented 10 months ago

I'm converting some build files in Grovy to KTS, and somehow the kotliner configuration does not work for subproject. It worked in Grovy. Is it still possible to do this or do I need to move this into every module build script?

Screenshot 2023-11-17 at 10 44 52

Eightyplus commented 10 months ago

Solved it by extracting setup to gradle file 😢

apply(from = rootProject.file("kotliner.gradle"))

subprojects {
    apply plugin: "org.jmailen.kotlinter"

    kotlinter {
        ignoreFailures = false
        reporters = ['checkstyle', 'plain', 'html']
        disabledRules = ['trailing-comma-on-call-site', 'trailing-comma-on-declaration-site']
    }
}
Eightyplus commented 10 months ago

found yet another solution 🤦

subprojects {
    apply(plugin = "org.jmailen.kotlinter")

    configure<KotlinterExtension> {
        ignoreFailures = false
        reporters = arrayOf("checkstyle", "plain", "html")
        disabledRules = arrayOf("trailing-comma-on-call-site", "trailing-comma-on-declaration-site")
    }
}