https://kotlinlang.org logo
#ktlint
Title
# ktlint
r

Rodrigo Munera

10/20/2023, 4:06 PM
I'm trying to migrate a project from groovy DSL into Kotlin DSL with version catalogs (libs.versions.toml) and I'm facing a strange issue when migrating my ktlint declarations from groovy to kotlin. My issue is that in my kotlin DSL gradle.build.tk file the ktlintFormat and ktlintCheck references are not found. should they just be string literals? or did I miss something in my plugins definitions? Here's the original groovy build.gradle file
Copy code
plugins {
    id "org.jlleitschuh.gradle.ktlint" version "10.3.0"
}

allprojects { project ->
    apply plugin: "org.jlleitschuh.gradle.ktlint"
    ktlint {
        version = "0.43.0"
        debug = false
        verbose = false
        android = true
        outputToConsole = true
        reporters {
            reporter "plain"
            reporter "checkstyle"
        }
        ignoreFailures = !enforceStaticAnalysis
        disabledRules = ["import-ordering"]
    }
}
task styleChecksFormat {
    group 'formatting'
    dependsOn 'ktlintFormat'
}

task styleChecks {
    group 'verification'
    dependsOn 'ktlintCheck'
}
And this is my kotlin DSL file
Copy code
plugins {
    alias(libs.plugins.ktlint).apply(true)
}
allprojects {
    apply(plugin = "org.jlleitschuh.gradle.ktlint")
    ktlint {
        version.set("11.6.1")
        debug.set(false)
        verbose.set(false)
        android.set(true)
        outputToConsole.set(true)
        outputColorName.set("RED")
        ignoreFailures.set(true)
        enableExperimentalRules.set(false)
        reporters {
            reporter(ReporterType.PLAIN)
            reporter(ReporterType.CHECKSTYLE)
        }
        kotlinScriptAdditionalPaths {
            include(fileTree("scripts/"))
        }
        filter {
            exclude("**/generated/**")
            include("**/kotlin/**")
        }
    }
}
task("styleChecksFormat") {
    group = "formatting"
    dependsOn(klintFormat)
}
task("styleChecks") {
    group = "verification"
    dependsOn(ktlintCheck)
}
w

wakingrufus

10/20/2023, 6:22 PM
in the dependsOn part?
dependsOn(tasks.named("klintFormat"))
etc
r

Rodrigo Munera

10/20/2023, 7:28 PM
yeah, that was the part.
I went down a rabbit hole trying to upgrade the project from gradle 7.6.2 to 8+ and ended up rage quitting that part
6 Views