Scrivio Interview library
DebuggingIntermediate7 min read · updated 12 November 2026

After upgrading Gradle by one major version, the build fails with errors about removed APIs in a third-party plugin and the configuration cache reports many problems. How do you get the upgrade done?

I would start with the upgrade guide for the new version, which lists removed APIs and behaviour changes, and a build scan or --warning-mode all to see where deprecations come from. The plugin failure is fixed by upgrading that plugin to a version built for the new Gradle, or by replacing it or forking it temporarily if none exists. Configuration cache problems almost always mean tasks reading project state at execution time, so we rewrite our custom tasks to use providers and declared inputs, and temporarily mark third-party tasks that cannot be fixed yet as incompatible. In future we upgrade one major version at a time, clearing deprecations at each step.

Why this question is asked

Major Gradle upgrades are where years of small shortcuts come due. Gradle removes APIs it deprecated during the previous major line, so a plugin that ignored its deprecation warnings simply stops loading, and builds that turned on the configuration cache during the upgrade suddenly see dozens of problems. Interviewers ask this to see whether we can work through such a failure methodically instead of rolling back and giving up. In this answer, we will read the failures and the upgrade guide, fix the third-party plugin, understand and fix configuration cache problems in our own tasks, handle tasks we cannot fix yet, and set up a safer upgrade path for next time.

1Reading the Failures and the Upgrade Guide

The first error usually comes from a plugin, and it looks like a Java linkage error rather than a Gradle message, because the plugin was compiled against an API that no longer exists.

Shell
./gradlew build
# Typical shapes of the failure (exact class names depend on the plugin and version):
# An exception occurred applying plugin request [id: 'com.example.codegen', version: '2.3.1']
# > Failed to apply plugin 'com.example.codegen'.
# > org/gradle/api/plugins/JavaPluginConvention
# (java.lang.NoClassDefFoundError)
# 1. Read the upgrade guide for the target version (Upgrading your build from Gradle N to N+1)
# 2. Find where removed APIs are used:
./gradlew help --scan # the build scan's deprecations view lists each source
# or, on the OLD Gradle version:
./gradlew build --warning-mode all

Notice the NoClassDefFoundError naming a Gradle class: the plugin refers to a type that was removed. The convention API used in this example, JavaPluginConvention, was deprecated in Gradle 8 and removed in Gradle 9, and many old plugins used it. The upgrade guide names such removals and their replacements, so reading it first saves guessing. The build scan, or --warning-mode all run on the old version, attributes each deprecation to a plugin or script, which gives us a list of everything to fix, not just the first failure.

2Fixing the Third-Party Plugin

For the plugin, there are four options, in order of preference. First, upgrade it: most maintained plugins publish a release for each Gradle major, and the plugin's release notes or the Gradle Plugin Portal show which version supports which Gradle. Second, if the plugin is abandoned, look for an alternative, possibly a core Gradle feature that has replaced it. Third, fork it temporarily, fix the removed API calls, which are usually small mechanical changes, and publish the fork to the internal repository with a clear note to return to upstream. Fourth, as a last resort, stay on the previous Gradle version until one of the other options is ready.

Whatever we choose, we track it explicitly. A temporary fork with no owner becomes a permanent fork, and in two years it blocks the next upgrade.

Step throughHandling a plugin that breaks on the new Gradle
  1. Compatible release of the plugin?release notes, plugin portal
    YesUpgrade the pluginNoAlternative or core feature?
  2. Alternative or core feature?
    YesSwitch to itNoCan we fork and fix it?
  3. Can we fork and fix it?usually a few API replacements
    YesPublish an internal fork, track itNoStay on the old Gradle for now

3 steps in order. Play them, or step through them one at a time.

3Why the Configuration Cache Reports Problems

The configuration cache saves the result of the configuration phase, the graph of tasks with their configured values, and reuses it on the next build without running the build scripts. For that to be correct, a task must carry everything it needs as its own values. It must not reach back into the Project object, other tasks or global state when it runs, because on a cached build those objects are not configured at all.

Each problem in the report, which Gradle writes as an HTML file under build/reports/configuration-cache, points at a place where a task breaks that rule. The most common one in custom tasks looks like this.

Java
// Before: reads project state at execution time
tasks.register("copyDocs") {
doLast {
project.copy { // problem: invocation of 'Task.project' at execution time
from("docs"); into(project.layout.buildDirectory.dir("site"))
}
println("env=" + System.getenv("DEPLOY_ENV")) // undeclared input
}
}
// After: declared inputs, outputs and an injected service
abstract class CopyDocs : DefaultTask() {
@get:InputDirectory @get:PathSensitive(PathSensitivity.RELATIVE) abstract val source: DirectoryProperty
@get:OutputDirectory abstract val target: DirectoryProperty
@get:Input abstract val env: Property<String>
@get:Inject abstract val fs: FileSystemOperations
@TaskAction fun run() {
fs.copy { from(source); into(target) }
logger.lifecycle("env=${env.get()}")
}
}
tasks.register<CopyDocs>("copyDocs") {
source = layout.projectDirectory.dir("docs")
target = layout.buildDirectory.dir("site")
env = providers.environmentVariable("DEPLOY_ENV").orElse("dev")
}
// ./gradlew copyDocs --configuration-cache -> Configuration cache entry stored.
// ./gradlew copyDocs --configuration-cache -> Reusing configuration cache.

Notice the three changes. The copy is done through FileSystemOperations, a service Gradle injects into the task, instead of project.copy. The directories are declared properties set during configuration, so they are stored in the cache. And the environment variable is read through providers, which tells Gradle to invalidate the cache entry if it changes. As a bonus, the task now has declared inputs and outputs, so it can be UP-TO-DATE as well.

4Tasks We Cannot Fix Yet

Some problems come from third-party tasks we cannot change today. Rather than turning the configuration cache off for the whole build, we can mark those specific tasks as not compatible. Gradle then disables the cache only for builds that run them and explains why, while every other build keeps the benefit.

Java
tasks.named("legacyReport") {
notCompatibleWithConfigurationCache("uses Task.project at execution time; plugin fix tracked in BUILD-142")
}
// While fixing problems, the build can report them without failing:
// ./gradlew build --configuration-cache --configuration-cache-problems=warn

The warn mode is useful during the cleanup, because it lists every problem in one report instead of stopping at the first. But it should be temporary: a build that always runs in warn mode collects new problems silently. Once the list is empty, we enable the cache in gradle.properties with org.gradle.configuration-cache=true.

5Upgrading One Major Version at a Time

The failures in this scenario usually mean the build skipped steps or ignored warnings. The safer routine is to upgrade one major version at a time, and on each version run with --warning-mode all, fix every deprecation, including those from plugins by upgrading them, and only then move to the next major. In CI, --warning-mode fail keeps new deprecations from creeping in between upgrades.

Within a major line, upgrading to each minor release shortly after it appears keeps every step small. Gradle deprecates in minor releases and removes in majors, so a build that stays warning-free on the latest minor of a line is usually ready for the next major with only the changes the upgrade guide lists.

Step throughA safe major upgrade
  1. Latest minor of the current majore.g. the last 8.x
  2. --warning-mode all, fix deprecationsown scripts and plugin upgrades
  3. Read the upgrade guide for N+1removed APIs, behaviour changes
  4. Bump the wrapper to N+1build, test, build scan
  5. Fix config cache problemsproviders, declared inputs, mark the rest
  6. CI with --warning-mode failkeep it clean until the next upgrade

6 steps in order. Play them, or step through them one at a time.

6Follow-up questions

Why does the configuration cache care about Task.project?

Because on a build that reuses the cache, the build scripts never run, so the Project object is not configured. A task that reads it at execution time would see a different state than it did when the cache entry was stored, or nothing at all. Gradle forbids it so that a cached build behaves exactly like a fresh one.

Should I roll back the upgrade if it breaks?

Roll back the wrapper commit to unblock the team, yes, but keep the upgrade branch and the list of problems. The fixes, upgraded plugins and rewritten tasks, can mostly be merged on the old version first, which makes the next attempt a small version bump.

How do I know which plugin version supports a Gradle version?

Plugins usually say so in their release notes or documentation, and Gradle's own compatibility notes cover core integrations such as Kotlin and Android. Running the plugin's latest release in a branch with the new wrapper and a build scan is the quickest practical test.

7Conclusion

In this answer, we worked through a failed major Gradle upgrade. The upgrade guide lists removed APIs and behaviour changes, and a build scan or --warning-mode all shows where deprecations come from. A plugin that uses removed APIs is upgraded to a compatible version, replaced, or forked temporarily. Configuration cache problems point to tasks reading project state at execution time, which we fix with injected services, providers and declared inputs, marking incompatible third-party tasks while they are fixed. Upgrading one major version at a time with deprecations cleared at each step prevents most of this.

What to say in the interviewAbout 90 seconds aloud

Open with

First I would read the upgrade guide for the target version, because it lists exactly which APIs were removed and which behaviours changed, and I would get a build scan, or run the old version with warning mode all, to see every deprecation and which plugin or script causes it.

Then, if they want more

The plugin error is usually a NoClassDefFoundError or NoSuchMethodError on a Gradle class, for example the old convention API that Gradle 9 removed.

The fix is to upgrade that plugin to a release built for the new Gradle; if there is none, I look for an alternative or a core feature, and as a last resort fork it, fix the API calls and publish it internally with a ticket to return to upstream.

For the configuration cache, the report under build/reports tells me which tasks break the rules. Nearly always it is a task touching project at execution time, like project.copy in a doLast, or reading environment variables directly. I rewrite our own tasks with declared inputs and outputs, injected services like FileSystemOperations, and providers for environment values.

For third-party tasks I cannot fix yet, I mark them notCompatibleWithConfigurationCache with a reason, so the rest of the build keeps the cache. And for the future I upgrade one major at a time, clearing all deprecations on the latest minor first, with warning mode fail in CI.

About this answer

Last updated
12 November 2026
Checked
Its structure and format are checked automatically. Use it as a carefully prepared study note: where a detail matters, confirm it against the documentation below. What the checks cover
Where the question comes from
Written by Scrivio for practice. It is not taken from an interview.
Official documentation
Gradle user manual
Report an issue with this answer

Copy the line below and send it to the author with what you found. It carries the address of this page.

Issue with "After upgrading Gradle by one major version, the build fails with errors about removed...": https://scrivio-interview-library.netlify.app/java/gradle/d08dfd34f8/