ktlint icon indicating copy to clipboard operation
ktlint copied to clipboard

Android gradle preBuild task build output

Open robgravy opened this issue 6 years ago • 6 comments

We've added ktlint to our android project and included it in our gradle scripts.

preBuild.dependsOn ktlint

Is there a way to view the lint errors with line numbers in this build output here:

gradle_build_output

I have to re-run the ktlint gradle task again to get the line numbers and list of errors, seen below here:

ktlint_output

robgravy avatar May 17 '19 22:05 robgravy

I have also tried the same approach stuck with with issue, it would be nice if someone can help on this.

ajaypro avatar May 26 '19 05:05 ajaypro

@gray419 sorry for not seeing this sooner. can you post a more complete snippet of your gradle script?

shashachu avatar Jul 17 '19 06:07 shashachu

complete ktlint.gradle file `repositories { jcenter() }

configurations { ktlint }

dependencies { ktlint "com.github.shyiko:ktlint:0.29.0" }

task ktlint(type: JavaExec, group: "verification") { description = "Check Kotlin code style." classpath = configurations.ktlint main = "com.github.shyiko.ktlint.Main" args "src/**/*.kt" }

preBuild.dependsOn(ktlint)

task ktlintFormat(type: JavaExec, group: "formatting") { description = "Fix Kotlin code style violations." classpath = configurations.ktlint main = "com.github.shyiko.ktlint.Main" args "-F", "src/**/*.kt" }`

ajaypro avatar Jul 17 '19 07:07 ajaypro

Same issue here, this really effects the decision to use the linter or not.

danielsmarantz avatar May 14 '20 18:05 danielsmarantz

Getting the same issue as well on our team. We're on Android Studio 4.0 and Gradle Plugin 4.0.0.

This is our ktlint.gradle file:

configurations {
    ktlint
}

dependencies {
    ktlint "com.pinterest:ktlint:0.37.2"
}

task ktlint(type: JavaExec, group: "verification") {
    description = "Check Kotlin code style."
    main = "com.pinterest.ktlint.Main"
    classpath = configurations.ktlint
    args "src/**/*.kt", "!src/test/**/*Test.kt" //ignore test files
    // to generate report in checkstyle format prepend following args:
    // "--reporter=plain", "--reporter=checkstyle,output=${buildDir}/ktlint.xml"
    // see https://github.com/pinterest/ktlint#usage for more

}

task ktlintFormat(type: JavaExec, group: "formatting") {
    description = "Fix Kotlin code style deviations."
    main = "com.pinterest.ktlint.Main"
    classpath = configurations.ktlint
    args "-F", "src/**/*.kt"
}

preBuild.dependsOn(ktlint)
check.dependsOn(ktlint)

jasenmoloy avatar Jul 15 '20 23:07 jasenmoloy

I am failing to understand what you exactly want to achieve. If this issue is still relevant for any of you, please update the issue with its goal.

paul-dingemans avatar Jun 28 '22 16:06 paul-dingemans

@Goooler Can you please advise whether this issue is still relevant or that we should close it?

paul-dingemans avatar Mar 27 '23 15:03 paul-dingemans

I can view the error lines with the latest ktlintCheck, suggest you can try out Kotlinter in your Gradle integrations.

image

Goooler avatar Mar 27 '23 16:03 Goooler