Skip to content

After updating dependencies ktlint compiles the application #950

@sereden

Description

@sereden

ktlintCheck triggers a full application assembly after Gradle 8.12.1 and KSP 2.2.10 upgrade instead of performing a static code analysis check.

./gradlew ktlintCheck forces a complete rebuild of the application, including tasks like mergeDebugAndroidTestResources and compileReleaseKotlinAndroid, before running the lint checks. This significantly increases build time.

Dependency Previous Version Current Version
AGP 8.9.2 8.12.1
Gradle Wrapper 8.11.1 8.13
Kotlin 2.1.20 2.2.10
Ktlint 12.2.0 13.1.0

The configuration is the following

fun configureKtlintKsp(project: Project){
        project.afterEvaluate {
            tasks.named("runKtlintCheckOverCommonMainSourceSet") {
                dependsOn("kspCommonMainKotlinMetadata")
            }
            tasks.named("runKtlintFormatOverCommonMainSourceSet") {
                dependsOn("kspCommonMainKotlinMetadata")
            }
        }
    }

    fun configureKtlint(project: Project) {
        project.extensions.configure<KtlintExtension> {
            verbose.set(true)
            android.set(false) // keep false, or true only if you want Android-specific formatting rules
            outputColorName.set("RED")
            filter {
                // Lint ALL Kotlin files by default
                include("**/*.kt")

                // Exclude generated / build / irrelevant dirs
                exclude("**/build/**")
                exclude("**/generated/**")
                exclude("**/.gradle/**")
                exclude("**/ios*/**")
                exclude("**/kapt*/**")
                exclude("**/ksp/**")
                exclude("**/resources/**") // catches Compose stubs, R classes, etc.
            }
        }
    }

Does anyone experience the same problem?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions