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
- Re-run the printed Maven command (compileArgs.showCommand()) manually to see the full compiler error output.
- Fix the compilation errors or dependency issues reported by Maven.
- 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
- Run `mvn compile` (or ./mvnw compile) manually before invoking the CLI wrapper.
- Keep JAVA_HOME pointing at a supported JDK.
- Ensure ~/.m2/settings.xml repositories are reachable (check offline/proxy config).
- Fix compiler errors reported by Maven before re-running delegated builds.
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
- The specified %s identifier (%s) contains invalid characters
- The requested Maven version <requiredMavenVersionRange> is i
- More than one @QuarkusMain method found with name '${name}':
- Unable to determine groupId and artifactId of the jar that c
- Unable to determine groupId and artifactId of the extension
AI-assisted analysis of quarkusio/quarkus@e1c734241f (2026-09-05).
Data as JSON: /api/errors/b2d8fe84551d2063.
Report an issue: GitHub.