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

Carter

02/28/2024, 8:31 PM
With the 1.2.0 release, I seem to be having trouble with the CLI arguments for writing a checkstyle report to a file.
With a Gradle script along the lines of
Copy code
val outputDir = File(File(layout.buildDirectory.asFile.get(), "reports"), "ktlint")
    val outputFile = File(outputDir, "ktlint.xml")
    val ktlintArgs = listOf(
        "--reporter=checkstyle,output=${outputFile.path}",
        "**/src/**/*.kt",
        "!**/build/**.kt",
        "--baseline=$baselineFile",
        "--editorconfig=$editorConfigFile"
    )

    register("ktlint", org.gradle.api.tasks.JavaExec::class) {
        description = "Analyze code style with ktlint."
        classpath = ktlint
        mainClass = "com.pinterest.ktlint.Main"
        args = ktlintArgs
    }
The result is
Copy code
15:29:57.715 [main] ERROR com.pinterest.ktlint.cli.internal.ReporterAggregator -- reporter "output=build/reports/ktlint/ktlint.xml" wasn't found (available: baseline, checkstyle, format, html, json, plain, plain-summary, sarif)
Reading the error message, it seems like something might have changed with the CLI parsing? It seems like the reporter parsing has dropped the
checkstyle,
Is this a bug? Or is there a change to the CLI that I need to accomodate with the 1.2 release?
p

Paul Dingemans

02/28/2024, 8:46 PM
Can you please create an issue? Most likely it is bug. The CLI parser has been replaced.
c

Carter

02/29/2024, 11:20 AM