ktlint
ktlint copied to clipboard
Android gradle preBuild task build output
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:

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

I have also tried the same approach stuck with with issue, it would be nice if someone can help on this.
@gray419 sorry for not seeing this sooner. can you post a more complete snippet of your gradle script?
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" }`
Same issue here, this really effects the decision to use the linter or not.
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)
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.
@Goooler Can you please advise whether this issue is still relevant or that we should close it?
I can view the error lines with the latest ktlintCheck, suggest you can try out Kotlinter in your Gradle integrations.