quarkusio/quarkus · error · MojoExecutionException

Failed to create the output dir ${projectFile}

Error message

Failed to create the output dir ${projectFile}

What it means

QuarkusBootstrapProvider.getApplicationArtifactBuilder represents the current Maven project as a resolved application artifact for the Quarkus bootstrap. When the project artifact file does not exist yet (project not compiled), it falls back to the configured output directory and attempts mkdirs(); if directory creation fails (permissions, path is a file, disk issues) it throws this MojoExecutionException naming the directory.

Source

Thrown at devtools/maven/src/main/java/io/quarkus/maven/QuarkusBootstrapProvider.java:519

        private ResolvedDependencyBuilder getApplicationArtifactBuilder(QuarkusBootstrapMojo mojo)
                throws MojoExecutionException {
            String appArtifactCoords = mojo.appArtifactCoords();
            if (appArtifactCoords == null) {
                final Artifact projectArtifact = mojo.mavenProject().getArtifact();

                File projectFile = projectArtifact.getFile();
                if (projectFile == null) {
                    projectFile = new File(mojo.mavenProject().getBuild().getOutputDirectory());
                    if (!projectFile.exists()) {
                        /*
                         * TODO GenerateCodeMojo would fail
                         * if (hasSources(project)) {
                         * throw new MojoExecutionException("Project " + project.getArtifact() + " has not been compiled yet");
                         * }
                         */
                        if (!projectFile.mkdirs()) {
                            throw new MojoExecutionException("Failed to create the output dir " + projectFile);
                        }
                    }
                }
                return ResolvedDependencyBuilder.newInstance()
                        .setGroupId(projectArtifact.getGroupId())
                        .setArtifactId(projectArtifact.getArtifactId())
                        .setClassifier(projectArtifact.getClassifier())
                        .setType(projectArtifact.getArtifactHandler().getExtension())
                        .setVersion(projectArtifact.getVersion())
                        .setResolvedPath(projectFile.toPath());
            }

            final String[] coordsArr = appArtifactCoords.split(":");
            if (coordsArr.length < 2 || coordsArr.length > 5) {
                throw new MojoExecutionException(
                        "appArtifact expression " + appArtifactCoords
                                + " does not follow format groupId:artifactId:classifier:type:version");
            }

View on GitHub (pinned to e1c734241f)

Solutions

  1. Run mvn compile (or mvn package) before the Quarkus mojo so the project artifact file exists
  2. Check filesystem permissions on the module's target/ directory and ensure the build user can write
  3. Verify the path named in the error is not an existing regular file blocking directory creation
  4. Check available disk space and any sandbox/readonly-mount restrictions
  5. Set appArtifactCoords explicitly to a resolvable artifact if the project artifact is intentionally absent

Example fix

// CI pipeline
// before — Quarkus mojo runs before compilation
mvn quarkus:build
// after — compile first so the artifact file exists
mvn compile quarkus:build
Defensive patterns

Strategy: validation

Validate before calling

// Before invoking the Quarkus mojo, verify the output directory is creatable
File outDir = new File(project.getBuild().getOutputDirectory());
if (!outDir.exists() && !outDir.getParentFile().canWrite()) {
    throw new IllegalStateException("Cannot write to build output directory: " + outDir.getParentFile());
}
if (outDir.exists() && !outDir.isDirectory()) {
    throw new IllegalStateException("Build output path exists and is not a directory: " + outDir);
}

Try / catch

try {
    quarkusMojo.execute();
} catch (MojoExecutionException e) {
    if (e.getMessage().startsWith("Failed to create the output dir")) {
        File dir = new File(e.getMessage().substring(e.getMessage().lastIndexOf(' ') + 1));
        getLog().error("Cannot create " + dir + ": check permissions, that the path is not a file, and disk space.");
    } else { throw e; }
}

Prevention

When it happens

Trigger: mojo.appArtifactCoords() is null, projectArtifact.getFile() returns null (project not yet packaged/compiled), the target output directory does not exist, and File.mkdirs() returns false because the directory could not be created.

Common situations: Running quarkus mojos on a clean project without a prior compile; read-only workspace or CI checkout with restrictive permissions; a file already exists at the target/classes path; running from a sandboxed environment denying writes to the module directory; disk-full conditions.

Related errors


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