quarkusio/quarkus · error · QuarkusUpdateException

Error while running Gradle rewrite command, see the executio

Error message

Error while running Gradle rewrite command, see the execution logs above for more details

What it means

runGradleUpdate() writes a temporary OpenRewrite init script (openrewrite-init.gradle), resolves the Gradle binary, and invokes gradle rewriteRun/rewriteDryRun via executeRewrite(). If anything fails in that flow other than a QuarkusUpdateException already thrown (e.g. the Gradle build fails, the init script cannot be written/read), it is wrapped in QuarkusUpdateException with a generic message telling the user to inspect the execution logs printed above.

Source

Thrown at independent-projects/tools/devtools-common/src/main/java/io/quarkus/devtools/project/update/rewrite/QuarkusUpdateCommand.java:124

                                "rewriteFile", rewriteFile,
                                "pluginVersion", rewritePluginVersion,
                                "recipesGAV", recipesGAV,
                                "activeRecipe", RECIPE_IO_QUARKUS_OPENREWRITE_QUARKUS,
                                "plainTextMask", ADDITIONAL_SOURCE_FILES_SET.stream()
                                        .map(s -> "\"" + s + "\"")
                                        .collect(Collectors.joining(", ")))));
            }
            final String gradleBinary = findGradleBinary(baseDir);
            List<String> command = List.of(gradleBinary.toString(), "--console", "plain", "--stacktrace",
                    "--init-script",
                    tempInit.toAbsolutePath().toString(), dryRun ? "rewriteDryRun" : "rewriteRun");
            Map<String, List<String>> commands = new LinkedHashMap<>();
            commands.put(getRewriteCommandName(rewritePluginVersion, dryRun), command);
            executeRewrite(baseDir, commands, log, logFile);
        } catch (QuarkusUpdateException e) {
            throw e;
        } catch (Exception e) {
            throw new QuarkusUpdateException(
                    "Error while running Gradle rewrite command, see the execution logs above for more details", e);
        } finally {
            if (tempInit != null) {
                try {
                    Files.deleteIfExists(tempInit);
                } catch (Exception e) {
                    // ignore
                }
            }

        }
    }

    private static String getMavenSettingsArg() {
        final String mavenSettings = System.getProperty("maven.settings");
        if (mavenSettings != null) {
            return Files.exists(Paths.get(mavenSettings)) ? mavenSettings : null;
        }

View on GitHub (pinned to e1c734241f)

Solutions

  1. Read the Gradle execution output printed just above the error (and the --stacktrace output); the root cause is there, not in this message.
  2. Make sure the project compiles first: run `./gradlew compileJava compileTestJava` and fix errors before re-running the update.
  3. Verify network/repo access to Maven Central so the OpenRewrite Gradle plugin and recipes GAV can be resolved.
  4. Re-run with a dry run first (`quarkus update --dry-run`) to isolate recipe failures from applied changes.
  5. If the nested cause shows a missing init-script resource, verify the quarkus update CLI and extension versions are consistent (do not mix a newer CLI with older devtools).

Example fix

// before: update fails because the project does not compile
$ quarkus update
Error while running Gradle rewrite command, see the execution logs above for more details
  Caused by: ... compilation error

// after: fix compilation first, then update
$ ./gradlew compileJava   # fix reported errors
$ quarkus update
Defensive patterns

Strategy: try-catch

Validate before calling

import java.nio.file.*;

static void validateGradleProject(Path baseDir) throws IllegalStateException {
    if (!(Files.exists(baseDir.resolve("build.gradle"))
            || Files.exists(baseDir.resolve("build.gradle.kts")))) {
        throw new IllegalStateException("No Gradle build file in " + baseDir);
    }
    if (!Files.isExecutable(baseDir.resolve("gradlew"))
            && nativeCommand("gradle") == null) {
        throw new IllegalStateException("gradlew missing in project and gradle not on PATH");
    }
}

Try / catch

try {
    QuarkusUpdateCommand.handle(log, BuildTool.GRADLE, baseDir, rewritePluginVersion, recipesGAV, recipe, logFile, dryRun);
} catch (QuarkusUpdateException e) {
    // real cause is in the nested exception / printed Gradle logs
    e.getCause().printStackTrace();
    log.error("Gradle rewrite failed: %s. Check the Gradle output above and the log file %s.",
        e.getCause() != null ? e.getCause().getMessage() : e.getMessage(), logFile);
}

Prevention

When it happens

Trigger: QuarkusUpdateCommand.handle() -> runGradleUpdate() on a Gradle project where: (a) the Gradle rewriteRun/rewriteDryRun execution exits with an error (compilation failures, recipe/plugin download failures, incompatible Gradle version), (b) the classpath resource /openrewrite-init.gradle is missing (inputStream null), or (c) reading/writing the temp init script throws IOException.

Common situations: Running `quarkus update` on a Gradle project whose code does not compile before migration, corporate proxies or repositories blocking download of the OpenRewrite Gradle plugin, or a Gradle version too old for the rewrite plugin's API (e.g. rewriteDryRun task missing).

Related errors


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