Skip to content

Log issues at ERROR level with ignoreFailures = false#1038

Open
jonasfa wants to merge 4 commits intoJLLeitschuh:mainfrom
jonasfa:main
Open

Log issues at ERROR level with ignoreFailures = false#1038
jonasfa wants to merge 4 commits intoJLLeitschuh:mainfrom
jonasfa:main

Conversation

@jonasfa
Copy link
Copy Markdown

@jonasfa jonasfa commented Mar 20, 2026

What

The issues causing a build failure are most relevant, even when the user requests a quiet output.

Gradle plugins that print the issues causing a failure at ERROR level include:

Android Gradle Plugin (lint)
my-project % ./gradlew lint --quiet --rerun-tasks --console plain
Wrote HTML report to file:///Users/user/workspace/my-project/app/build/reports/lint-results-debug.html
Lint found 1 error. First failure:
/Users/user/workspace/my-project/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml:2: Error: The application adaptive icon is missing a monochrome tag [MonochromeLauncherIcon]
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
^


FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:lintDebug'.
> Lint found errors in the project; aborting build.

  Fix the issues identified by lint, or create a baseline to see only new errors.
  To create a baseline, run `gradlew updateLintBaseline` after adding the following to the module's build.gradle file:
  ```
  android {
      lint {
          baseline = file("lint-baseline.xml")
      }
  }
  ```
  For more details, see https://developer.android.com/studio/write/lint#snapshot

  /Users/user/workspace/my-project/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml:2: Error: The application adaptive icon is missing a monochrome tag [MonochromeLauncherIcon]
  <adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
  ^
  1 error

* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights from a Build Scan (powered by Develocity).
> Get more help at https://help.gradle.org.

BUILD FAILED in 6s
io.gitlab.arturbosch.detekt
my-project % ./gradlew detekt --quiet --rerun-tasks --console plain
/Users/user/workspace/my-project/module/src/commonMain/kotlin/Hello.kt:34:5: The function Hello is too long (61). The maximum length is 60. [LongMethod]


FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':module:detekt'.
> Analysis failed with 1 weighted issues.

* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights from a Build Scan (powered by Develocity).
> Get more help at https://help.gradle.org.

BUILD FAILED in 1s

Current ktlint-gradle behavior

Currently, when Gradle is invoked with log level QUIET, the issues causing a failure are missing from ktlint-gradle's output.

Proposed behavior

ktlint-gradle should log issues at ERROR level instead.

This PR results in the following output change when Gradle is invoked with --quiet:

  project % ./gradlew ktlintCheck --no-scan --rerun-tasks --quiet --console plain
+ /Users/user/workspace/project/module/src/main/kotlin/Hello.kt:5:30 Missing newline before "}" (standard:wrapping)
+ /Users/user/workspace/project/module/src/main/kotlin/Hello.kt:5:31 Missing newline before '}' (standard:statement-wrapping)

  FAILURE: Build failed with an exception.

  * What went wrong:
  Execution failed for task ':module:ktlintMainSourceSetCheck'.
  > A failure occurred while executing org.jlleitschuh.gradle.ktlint.worker.ConsoleReportWorkAction
     > KtLint found code style violations. Please see the following reports:
       - /Users/user/workspace/project/module/build/reports/ktlint/ktlintMainSourceSetCheck/ktlintMainSourceSetCheck.xml
       - /Users/user/workspace/project/module/build/reports/ktlint/ktlintMainSourceSetCheck/ktlintMainSourceSetCheck.txt
       - /Users/user/workspace/project/module/build/reports/ktlint/ktlintMainSourceSetCheck/ktlintMainSourceSetCheck.csv

  * Try:
  > Run with --stacktrace option to get the stack trace.
  > Run with --info or --debug option to get more log output.
  > Get more help at https://help.gradle.org.

  BUILD FAILED in 9s

The output remains unchanged when any other log level is requested, or when no log level is requested (default).

Reference

https://docs.gradle.org/current/userguide/logging.html#logLevels

@jonasfa jonasfa changed the title Log issues at error level instead of warn Log issues at ERROR level instead of WARNING Mar 20, 2026
@wakingrufus
Copy link
Copy Markdown
Collaborator

I think you make a valid point here, but I think the use case is a little more complex. I think it really should log at warn is ignoreFailures (on the extension) is true, and error when false. would you mind doing the work to pipe through that property and use it here? if not, I can pick this up when I have some time.

@jonasfa
Copy link
Copy Markdown
Author

jonasfa commented Apr 7, 2026

@wakingrufus thanks for the input! I've updated the tests and implementation, and rebased.
While I was at it, I've also added a test for ignoreFailures itself, as there wasn't one yet.
Let me know if you have any other concern or request.

@jonasfa jonasfa changed the title Log issues at ERROR level instead of WARNING Log issues at ERROR level with ignoreFailures=false Apr 7, 2026
@jonasfa jonasfa changed the title Log issues at ERROR level with ignoreFailures=false Log issues at ERROR level with ignoreFailures = false Apr 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants