quarkusio/quarkus · error · RuntimeException

Failed to compile. Compilation exited with exit code:${exitC

Error message

Failed to compile. Compilation exited with exit code:${exitCode}

What it means

BuildToolDelegatingCommand.prepareMaven runs the Maven compile/goals via the configured runner and, if the process exits non-zero (exit code != ExitCode.OK), wraps the failure in a RuntimeException. This surfaces that the underlying Maven build failed, not a problem in the CLI itself.

Source

Thrown at devtools/cli-common/src/main/java/io/quarkus/cli/common/BuildToolDelegatingCommand.java:135

    }

    public void prepareMaven(BuildToolContext context) {
        BuildSystemRunner runner = getRunner(context);
        BuildSystemRunner.BuildCommandArgs compileArgs = runner.prepareAction("resources:resources",
                context.getBuildOptions(),
                context.getRunModeOption(),
                context.getParams());

        //Let's check if we need to precompile and if so, include the command to the dry-run output.
        //Note, that if the command should delegate to a the parent command dry-run output should be handled by the parent.
        if (getParentCommand().isPresent()) {
            return;
        } else if (context.getRunModeOption().isDryRun()) {
            output.info(" " + compileArgs.showCommand());
        } else {
            int compileExitCode = runner.run(compileArgs);
            if (compileExitCode != ExitCode.OK) {
                throw new RuntimeException("Failed to compile. Compilation exited with exit code:" + compileExitCode);
            }
        }
    }

    public void prepareGradle(BuildToolContext context) {
        if (!context.getParams().contains(GRADLE_NO_BUILD_CACHE)) {
            context.getParams().add(GRADLE_NO_BUILD_CACHE);
        }

        if (!context.getParams().contains(GRADLE_NO_DAEMON)) {
            context.getParams().add(GRADLE_NO_DAEMON);
        }
        if (!context.getForcedExtensions().isEmpty()) {
            GradleInitScript.populateForExtensions(context.getForcedExtensions(), context.getParams());
        }
    }

    public Map<BuildTool, String> getActionMapping() {

View on GitHub (pinned to e1c734241f)

Solutions

  1. Re-run the printed Maven command (compileArgs.showCommand()) manually to see the full compiler error output.
  2. Fix the compilation errors or dependency issues reported by Maven.
  3. Verify JAVA_HOME and Maven wrapper availability, and check network/repository settings if dependencies failed to resolve.

Example fix

// before
./mvnw -DskipTests package   // fails: cannot find symbol
// after: fix the source error, e.g. add missing import
import com.example.GeneratedDto;
Defensive patterns

Strategy: try-catch

Validate before calling

// pre-check before delegating
Process p = new ProcessBuilder("mvn", "-v").start();
if (p.waitFor() != 0) throw new IllegalStateException("Maven not available");

Try / catch

try {
    command.prepare(context);
} catch (RuntimeException e) {
    if (e.getMessage() != null && e.getMessage().contains("Failed to compile")) {
        int code = Integer.parseInt(e.getMessage().substring(e.getMessage().lastIndexOf(':') + 1));
        log.error("Maven exited with code %d — inspect compiler output above".formatted(code));
    } else throw e;
}

Prevention

When it happens

Trigger: `quarkus build`/dev-mode entry delegating to Maven when `mvn <compileArgs>` returns a non-zero exit code — e.g. compilation errors, missing dependencies, or Maven itself failing to start — outside dry-run mode.

Common situations: Java source compilation errors after a code change; broken pom.xml or missing repository access; wrong JAVA_HOME/Maven version; offline environment blocking dependency download.

Related errors


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