{"record":{"id":"b2d8fe84551d2063","repo":"quarkusio/quarkus","slug":"failed-to-compile-compilation-exited-with-exit-co","errorCode":null,"errorMessage":"Failed to compile. Compilation exited with exit code:${exitCode}","messagePattern":"Failed to compile\\. Compilation exited with exit code:(.+?)","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"devtools/cli-common/src/main/java/io/quarkus/cli/common/BuildToolDelegatingCommand.java","lineNumber":135,"sourceCode":"    }\n\n    public void prepareMaven(BuildToolContext context) {\n        BuildSystemRunner runner = getRunner(context);\n        BuildSystemRunner.BuildCommandArgs compileArgs = runner.prepareAction(\"resources:resources\",\n                context.getBuildOptions(),\n                context.getRunModeOption(),\n                context.getParams());\n\n        //Let's check if we need to precompile and if so, include the command to the dry-run output.\n        //Note, that if the command should delegate to a the parent command dry-run output should be handled by the parent.\n        if (getParentCommand().isPresent()) {\n            return;\n        } else if (context.getRunModeOption().isDryRun()) {\n            output.info(\" \" + compileArgs.showCommand());\n        } else {\n            int compileExitCode = runner.run(compileArgs);\n            if (compileExitCode != ExitCode.OK) {\n                throw new RuntimeException(\"Failed to compile. Compilation exited with exit code:\" + compileExitCode);\n            }\n        }\n    }\n\n    public void prepareGradle(BuildToolContext context) {\n        if (!context.getParams().contains(GRADLE_NO_BUILD_CACHE)) {\n            context.getParams().add(GRADLE_NO_BUILD_CACHE);\n        }\n\n        if (!context.getParams().contains(GRADLE_NO_DAEMON)) {\n            context.getParams().add(GRADLE_NO_DAEMON);\n        }\n        if (!context.getForcedExtensions().isEmpty()) {\n            GradleInitScript.populateForExtensions(context.getForcedExtensions(), context.getParams());\n        }\n    }\n\n    public Map<BuildTool, String> getActionMapping() {","sourceCodeStart":117,"sourceCodeEnd":153,"githubUrl":"https://github.com/quarkusio/quarkus/blob/e1c734241f34c7919086ceb4c9262b4a58f6de44/devtools/cli-common/src/main/java/io/quarkus/cli/common/BuildToolDelegatingCommand.java#L117-L153","documentation":"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.","triggerScenarios":"`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.","commonSituations":"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.","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."],"exampleFix":"// before\n./mvnw -DskipTests package   // fails: cannot find symbol\n// after: fix the source error, e.g. add missing import\nimport com.example.GeneratedDto;","handlingStrategy":"try-catch","validationCode":"// pre-check before delegating\nProcess p = new ProcessBuilder(\"mvn\", \"-v\").start();\nif (p.waitFor() != 0) throw new IllegalStateException(\"Maven not available\");","typeGuard":null,"tryCatchPattern":"try {\n    command.prepare(context);\n} catch (RuntimeException e) {\n    if (e.getMessage() != null && e.getMessage().contains(\"Failed to compile\")) {\n        int code = Integer.parseInt(e.getMessage().substring(e.getMessage().lastIndexOf(':') + 1));\n        log.error(\"Maven exited with code %d — inspect compiler output above\".formatted(code));\n    } else throw e;\n}","preventionTips":["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."],"tags":["cli","maven","build-failure","process-exit-code"],"backgroundTag":"build-tool-compilation-failed","analyzedSha":"e1c734241f34c7919086ceb4c9262b4a58f6de44","analyzedAt":"2026-09-05T17:01:29.979Z","contentChangedAt":"2026-09-05T17:01:29.979Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}