skip to content

--warning-mode & Deprecations

Using --warning-mode to surface deprecation warnings well before the release that removes the API. Interviewers ask because it is how you make a major upgrade boring instead of frightening.

on this pageshow

questions

5

After a build you see: 'Deprecated Gradle features were used in this build, making it incompatible with Gradle N.' What does this tell you and what should you do?

level: juniorimportance: must knowfreq 50%

answer

  1. printed by default summary mode
  2. build succeeded now, breaks on Gradle N
  3. re-run with all (+ stacktrace) to expand
  4. fix DSL or upgrade plugin
  5. lock with fail once clean

basics

~20 s

It means your build used something that will be removed in the next major Gradle (version N), so it would break after upgrading. Re-run with --warning-mode all to see the specific deprecations, then fix them.

solid answer

~40 s

That line is what the **default `summary` warning mode** prints: at least one deprecated feature was used, and as a result the build is not compatible with the next major version, `N`. It's a heads-up, not a failure — the build still succeeded on your current Gradle. The actionable step is to switch to `--warning-mode all` (optionally with `--stacktrace`) to expand the summary into the individual warnings and their origins, fix each (often by upgrading a plugin or rewriting a deprecated DSL call), and re-run until the summary line disappears. If you want the build to refuse to succeed while any deprecation exists, use `--warning-mode fail`. Ignoring the line means your eventual upgrade to Gradle `N` will break.

code

bash · 2 lines
bash
# Turn the one-line summary into the actual list of deprecations
./gradlew build --warning-mode all --stacktrace

go deeper

for a junior

Recognize the line as the default summary heads-up about the next major and know to re-run with all.

for a middle

Expand with all --stacktrace, fix DSL vs plugin offenders, and re-run until clean.

for a senior

Drive it to zero and lock with fail; explain the deprecate-then-remove-at-major lifecycle behind the message.

for a principal

Use the message as the trigger for an upgrade-readiness audit and standardize the clean-then-ratchet process across teams.

## Decoding the message Gradle's default mode is `summary`. Rather than spamming every warning, it collapses them into one closing line: *"Deprecated Gradle features were used in this build, making it incompatible with Gradle N."* Two facts are packed in: 1. **Something deprecated was used** — at least one API/DSL/behaviour on the removal track was exercised. 2. **The future-incompatible target is N** — the next major version where those features are removed. Your build works *now* but would break on `N`. It is informational; the build did not fail (unless you set `fail`). ## What to do ```bash # Expand the summary into the actual offenders and where they come from ./gradlew <task> --warning-mode all --stacktrace ``` Now each deprecation is printed individually with its message and, thanks to `--stacktrace`, its origin. Work through them: - **Your DSL** — rewrite the call to the recommended replacement named in the message. - **A plugin** — the stack trace points at the plugin package; upgrade that plugin to a version that doesn't use the deprecated API. Re-run until the summary line is gone, which means the build is clean and ready for the `N` upgrade. ## Locking it in Once clean, set `org.gradle.warning.mode=fail` so the summary line can never come back unnoticed: any reintroduced deprecation fails the build instead of printing a quiet count. ## Common misread The message is not saying the build *failed* or that you're already on an incompatible Gradle. You're fine today; the warning is about the *next* major. Treating it as noise is exactly how deprecation debt accumulates.

  • Does this message mean the build failed?
    No. Under the default `summary` mode the build still succeeds; it's an advisory that the build won't be compatible with the next major Gradle. Only `--warning-mode fail` turns deprecations into a failure.
  • The summary doesn't list which features were deprecated. How do you find them?
    Re-run with `--warning-mode all` (and `--stacktrace` for origins) to expand the count into the individual warnings.

saying these in an interview costs you the question

  • Interpreting the summary line as a build failure.
  • Thinking you're already on the incompatible version rather than being warned about the next major.
  • Ignoring the line as harmless noise.

context

open as a page

What does Gradle's --warning-mode flag do, and what are its possible values when you're preparing for a major-version upgrade?

level: juniorimportance: must knowfreq 55%

basics

~10 s

--warning-mode controls how Gradle shows warnings (mainly deprecations). Values: all, summary, none, fail. Use all to see every deprecation with details before upgrading to a new major Gradle version.

open as a page

You run with --warning-mode all and see a deprecation, but the message doesn't point at your build script. How do you find what actually triggered it?

level: middleimportance: should knowfreq 45%

basics

~10 s

Add --stacktrace to the run. Combined with --warning-mode all, Gradle prints a stack trace for each deprecation, so you can see whether it came from your build script or from a plugin.

open as a page

How would you use --warning-mode to make sure no new Gradle deprecations creep into a build between major-version upgrades?

level: seniorimportance: should knowfreq 38%

basics

~10 s

Set --warning-mode=fail (or org.gradle.warning.mode=fail) in CI. The build then fails whenever any deprecation is logged, so a new deprecation from code or a plugin upgrade is caught immediately.

open as a page

Where can you configure Gradle's warning mode, and what wins if both gradle.properties and the command line set it?

level: middleimportance: nice to knowfreq 25%

basics

~10 s

Set it via the CLI flag --warning-mode=<mode> or via org.gradle.warning.mode=<mode> in gradle.properties (or as a system property). The command-line flag takes precedence over gradle.properties.

open as a page