Improve error messages output when running tasks
Problem Description
When running ktlintCheck or ktlintFormat, if code style errors are found, the error message is not specific when the task fails, just mentioning a non-zero exit value after running the JavaExec in the runLint task.
This can cause some confusion and it's not very specific.
Suggested Solution:
Output error message when ktlintCheck finds code style errors: "Ktlint found X code styles errors, please fix them before continuing"
Output error message when ktlintFormat is not able to auto-correct: "Ktlint found X code styles errors that couldn't be auto-corrected, please fix them before continuing"
@Tapchicoma do we even have the information required to do this?
Generally, I think it is possible. Probably will require some changes in ktlint itself.
I initially thought this was an issue with AGP, but it is actually a problem caused by KTLint-gradle plugin
This problem is very easy to reproduce. Just create any sample project using the new Project wizard in Android Studio 4.x and prepend an extra space before super.onCreate()
When building the sample project, the build window will report the following false failure:
Process 'command '/Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java'' finished with non-zero exit value 1
However, if you run ./gradlew :app:ktlintAndroidTestSourceSetFormat you get back the syntax highlighting and line number of the failure, which is way more useful.
Is there a way to pipe the output of KTLint to the build window? Or alternatively, make KTLint failures behave like compile failures so that we can see the syntax highlighting and line number of the failure?
Even a message hinting about where the report files with further details can be found would be useful for Kotlin and/or Lint noobs like me