quarkusio/quarkus · error · UnsupportedOperationException

This operation is only supported for Gradle projects

Error message

This operation is only supported for Gradle projects

What it means

UpgradeGradlePluginOperation.single() generates rewrite recipe operations for upgrading a Gradle plugin version. For a GRADLE or GRADLE_KOTLIN_DSL project it returns the UpgradePluginVersion recipe parameters; for any other build tool it throws UnsupportedOperationException("This operation is only supported for Gradle projects"), since upgrading Gradle plugin versions has no meaning in Maven builds.

Solutions

  1. Only apply UpgradeGradlePluginOperation to Gradle projects — gate it on BuildTool.GRADLE / GRADLE_KOTLIN_DSL.
  2. For Maven projects, use the Maven rewrite plugin version upgrade operation instead.
  3. Verify the project's detected build tool before running plugin upgrade operations.

Example fix

// before
new UpgradeGradlePluginOperation(pluginIdPattern, newVersion).single(BuildTool.MAVEN, ...);
// after
if (buildTool == BuildTool.GRADLE || buildTool == BuildTool.GRADLE_KOTLIN_DSL) {
    new UpgradeGradlePluginOperation(pluginIdPattern, newVersion).single(buildTool, ...);
}
Defensive patterns

Strategy: type-guard

Validate before calling

if (buildTool != BuildTool.GRADLE && buildTool != BuildTool.GRADLE_KOTLIN_DSL) {
    return; // skip Gradle plugin upgrade operation for non-Gradle projects
}

Type guard

static boolean isGradle(BuildTool t) {
    return t == BuildTool.GRADLE || t == BuildTool.GRADLE_KOTLIN_DSL;
}

Try / catch

try {
    op.single(buildTool, ...);
} catch (UnsupportedOperationException e) {
    log.warn("Skipping Gradle plugin upgrade: " + e.getMessage());
}

Prevention

When it happens

Trigger: Calling UpgradeGradlePluginOperation.single() with a BuildTool other than GRADLE or GRADLE_KOTLIN_DSL — e.g. a MAVEN project — hits the default branch. Occurs when a build-tool-agnostic update flow applies the Gradle-plugin upgrade operation indiscriminately.

Common situations: Running a custom update recipe that includes the UpgradePluginVersion operation against a Maven project; a script that iterates operations without filtering by build tool; misdetected build tool when a Gradle plugin upgrade is requested on a Maven-only codebase.

Related errors


AI-assisted analysis of quarkusio/quarkus@e1c734241f (2026-09-05). Data as JSON: /api/errors/453f259db4064eb2. Report an issue: GitHub.

Appendix: source

Thrown at independent-projects/tools/devtools-common/src/main/java/io/quarkus/devtools/project/update/rewrite/operations/UpgradeGradlePluginOperation.java:27

    private final String pluginIdPattern;
    private final String newVersion;

    public UpgradeGradlePluginOperation(String pluginIdPattern, String newVersion) {
        this.pluginIdPattern = pluginIdPattern;
        this.newVersion = newVersion;
    }

    @Override
    public Map<String, Object> single(BuildTool buildTool) {
        switch (buildTool) {
            case GRADLE_KOTLIN_DSL:
            case GRADLE:
                return Map.of(
                        "org.openrewrite.gradle.plugins.UpgradePluginVersion",
                        Map.of("pluginIdPattern", pluginIdPattern, "newVersion", newVersion));
            default:
                throw new UnsupportedOperationException("This operation is only supported for Gradle projects");
        }
    }
}

View on GitHub (pinned to e1c734241f)