skip to content

How do you configure warning mode persistently, and how does org.gradle.warning.mode interact with the --warning-mode flag?

level: middleimportance: should knowfreq 35%

answer

  1. org.gradle.warning.mode property
  2. gradle.properties project vs user-home
  3. CLI flag overrides property
  4. default = summary
  5. commit all, CI passes fail

basics

~10 s

Set org.gradle.warning.mode=all|summary|none|fail in gradle.properties for a persistent default. The --warning-mode CLI flag overrides the property for a single build invocation.

solid answer

~30 s

You configure warning mode persistently with the `org.gradle.warning.mode` property, placed in either the project's `gradle.properties` (committed, team-wide) or `GRADLE_USER_HOME/gradle.properties` (per-developer machine). It accepts the same four values as the flag: `all`, `summary`, `none`, `fail`. The `--warning-mode` command-line flag takes precedence over the property, so it overrides it for that one invocation only. Precedence, highest to lowest: CLI flag → project `gradle.properties` → user-home `gradle.properties` → built-in default (`summary`). A common arrangement is committing `org.gradle.warning.mode=all` so everyone sees deprecations locally, while CI passes `--warning-mode fail` to enforce a clean build without changing the committed default.

code

toml · 4 lines
toml
# gradle.properties (not real TOML, shown as key=value)
# Persistent project-wide default — everyone sees deprecations locally
org.gradle.warning.mode=all
# CI then overrides per-run:  ./gradlew check --warning-mode fail

go deeper

for a junior

Know the property exists and that the CLI flag overrides it.

for a middle

State the exact property name, the file locations, and the precedence order.

for a senior

Design the commit-all / CI-fail split leveraging that the flag overrides the committed property.

for a principal

Standardize the property across repos and define where machine-vs-project defaults belong in the org's Gradle conventions.

## Two ways to set it Warning mode can be supplied per-invocation or persistently: - **Per-invocation:** `--warning-mode <mode>` on the command line. - **Persistent:** the `org.gradle.warning.mode` Gradle property. Both take the identical value set: `all`, `summary`, `none`, `fail`. ## Where the property lives `org.gradle.warning.mode` is a standard Gradle property, so it can be declared anywhere Gradle reads properties: ``` # <project>/gradle.properties — committed, applies to the whole team org.gradle.warning.mode=all ``` ``` # GRADLE_USER_HOME/gradle.properties (~/.gradle/gradle.properties) — per machine org.gradle.warning.mode=summary ``` It can also be supplied as a system/Gradle property on the command line via `-Dorg.gradle.warning.mode=...` or `-P`, but the dedicated `--warning-mode` flag is the idiomatic per-run override. ## Precedence From highest to lowest priority: 1. `--warning-mode` CLI flag 2. Project `gradle.properties` 3. `GRADLE_USER_HOME/gradle.properties` 4. Built-in default: `summary` So a project `gradle.properties` of `all` will be **overridden** by a CI command that passes `--warning-mode fail`, and the project value in turn overrides any user-home setting. ## Idiomatic split Commit `org.gradle.warning.mode=all` so local builds always surface deprecations, then have CI pass `--warning-mode fail`. Developers get diagnostics; CI gets enforcement; neither config fights the other because the flag wins for the CI run only.

  • If gradle.properties says 'all' and CI runs with --warning-mode fail, which wins?
    The CLI flag wins for that invocation, so the build runs in fail mode.
  • What's the difference between project and user-home gradle.properties for this setting?
    Project gradle.properties is committed and team-wide; user-home (~/.gradle) is per-developer and overridden by the project file.

saying these in an interview costs you the question

  • Claiming the property overrides the CLI flag — it's the reverse.
  • Saying the property name is gradle.warningMode or similar — it is org.gradle.warning.mode.

context