{"record":{"id":"453f259db4064eb2","repo":"quarkusio/quarkus","slug":"this-operation-is-only-supported-for-gradle-projec","errorCode":null,"errorMessage":"This operation is only supported for Gradle projects","messagePattern":"This operation is only supported for Gradle projects","errorType":"exception","errorClass":"UnsupportedOperationException","httpStatus":null,"severity":"error","filePath":"independent-projects/tools/devtools-common/src/main/java/io/quarkus/devtools/project/update/rewrite/operations/UpgradeGradlePluginOperation.java","lineNumber":27,"sourceCode":"\n    private final String pluginIdPattern;\n    private final String newVersion;\n\n    public UpgradeGradlePluginOperation(String pluginIdPattern, String newVersion) {\n        this.pluginIdPattern = pluginIdPattern;\n        this.newVersion = newVersion;\n    }\n\n    @Override\n    public Map<String, Object> single(BuildTool buildTool) {\n        switch (buildTool) {\n            case GRADLE_KOTLIN_DSL:\n            case GRADLE:\n                return Map.of(\n                        \"org.openrewrite.gradle.plugins.UpgradePluginVersion\",\n                        Map.of(\"pluginIdPattern\", pluginIdPattern, \"newVersion\", newVersion));\n            default:\n                throw new UnsupportedOperationException(\"This operation is only supported for Gradle projects\");\n        }\n    }\n}\n","sourceCodeStart":9,"sourceCodeEnd":31,"githubUrl":"https://github.com/quarkusio/quarkus/blob/e1c734241f34c7919086ceb4c9262b4a58f6de44/independent-projects/tools/devtools-common/src/main/java/io/quarkus/devtools/project/update/rewrite/operations/UpgradeGradlePluginOperation.java#L9-L31","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Only apply UpgradeGradlePluginOperation to Gradle projects — gate it on BuildTool.GRADLE / GRADLE_KOTLIN_DSL.","For Maven projects, use the Maven rewrite plugin version upgrade operation instead.","Verify the project's detected build tool before running plugin upgrade operations."],"exampleFix":"// before\nnew UpgradeGradlePluginOperation(pluginIdPattern, newVersion).single(BuildTool.MAVEN, ...);\n// after\nif (buildTool == BuildTool.GRADLE || buildTool == BuildTool.GRADLE_KOTLIN_DSL) {\n    new UpgradeGradlePluginOperation(pluginIdPattern, newVersion).single(buildTool, ...);\n}","handlingStrategy":"type-guard","validationCode":"if (buildTool != BuildTool.GRADLE && buildTool != BuildTool.GRADLE_KOTLIN_DSL) {\n    return; // skip Gradle plugin upgrade operation for non-Gradle projects\n}","typeGuard":"static boolean isGradle(BuildTool t) {\n    return t == BuildTool.GRADLE || t == BuildTool.GRADLE_KOTLIN_DSL;\n}","tryCatchPattern":"try {\n    op.single(buildTool, ...);\n} catch (UnsupportedOperationException e) {\n    log.warn(\"Skipping Gradle plugin upgrade: \" + e.getMessage());\n}","preventionTips":["Gate Gradle-plugin upgrade operations on a Gradle build tool check.","Use Maven-specific operations for Maven projects.","Verify the project's detected build tool before applying update operations.","Filter operation lists per build tool in custom update recipes."],"tags":["gradle","unsupported-operation","build-tool"],"backgroundTag":"unsupported-build-tool","analyzedSha":"e1c734241f34c7919086ceb4c9262b4a58f6de44","analyzedAt":"2026-09-05T17:01:29.979Z","contentChangedAt":"2026-09-05T17:01:29.979Z","schemaVersion":2},"datasetVersion":"2026-09-12T22:17:10.623Z"}