quarkusio/quarkus · error · MojoExecutionException

The parent project must have a packaging type of POM. Curren

Error message

The parent project must have a packaging type of POM. Current packaging: ${packaging}

What it means

When creating a Maven project with the quarkus-maven-plugin, if the target directory already contains a pom.xml, the plugin reads it as the prospective parent POM. A parent/aggregate POM must have packaging type `pom`; if the existing pom has a different packaging (jar, war, etc.), the mojo throws this MojoExecutionException because the new project would be added as a module of a non-aggregator POM.

Source

Thrown at devtools/maven/src/main/java/io/quarkus/maven/CreateProjectMojo.java:270

        Model parentPomModel = null;

        boolean containsAtLeastOneGradleFile = false;
        for (String gradleFile : Arrays.asList("build.gradle", "settings.gradle", "build.gradle.kts", "settings.gradle.kts")) {
            containsAtLeastOneGradleFile |= new File(projectRoot, gradleFile).isFile();
        }

        BuildTool buildToolEnum = BuildTool.findTool(buildTool);
        if (buildToolEnum == null) {
            String validBuildTools = String.join(",",
                    Arrays.asList(BuildTool.values()).stream().map(BuildTool::toString).collect(Collectors.toList()));
            throw new IllegalArgumentException("Choose a valid build tool. Accepted values are: " + validBuildTools);
        }
        if (BuildTool.MAVEN.equals(buildToolEnum)) {
            if (pom != null && pom.isFile()) {
                try {
                    parentPomModel = MojoUtils.readPom(pom);
                    if (!"pom".equals(parentPomModel.getPackaging())) {
                        throw new MojoExecutionException(
                                "The parent project must have a packaging type of POM. Current packaging: "
                                        + parentPomModel.getPackaging());
                    }
                } catch (IOException e) {
                    throw new MojoExecutionException("Could not access parent pom.", e);
                }
            } else if (containsAtLeastOneGradleFile) {
                throw new MojoExecutionException(
                        "You are trying to create a Maven project in a directory that contains only Gradle build files.");
            }
        } else if (BuildTool.GRADLE.equals(buildToolEnum) || BuildTool.GRADLE_KOTLIN_DSL.equals(buildToolEnum)) {
            if (containsAtLeastOneGradleFile) {
                throw new MojoExecutionException("Adding subprojects to gradle projects is not implemented.");
            } else if (pom != null && pom.isFile()) {
                throw new MojoExecutionException(
                        "You are trying to create gradle project in a directory that contains only maven build files.");
            }
        }

View on GitHub (pinned to e1c734241f)

Solutions

  1. Run the create goal in the root directory whose pom.xml has `<packaging>pom</packaging>`
  2. If the existing pom should be an aggregator, change its packaging to `<packaging>pom</packaging>`
  3. Create the project in a fresh empty directory instead
  4. Use `-DprojectGroupId/-DprojectArtifactId` with `-DoutputDirectory` pointing at the intended parent dir

Example fix

// before: existing parent pom.xml
<packaging>jar</packaging>
// after
<packaging>pom</packaging>
Defensive patterns

Strategy: validation

Validate before calling

File pom = new File(dir, "pom.xml");
if (pom.isFile() && !new String(Files.readAllBytes(pom.toPath())).contains("<packaging>pom</packaging>"))
    throw new IllegalStateException("Parent pom must have packaging 'pom'");

Try / catch

try {
    runCreateGoal();
} catch (MojoExecutionException e) {
    if (e.getMessage().startsWith("The parent project must have a packaging type of POM")) {
        // cd to the aggregator directory or fix the packaging
    }
}

Prevention

When it happens

Trigger: Running `mvn quarkus:create` inside a directory whose pom.xml has packaging jar/war instead of pom, intending to generate the new app as a submodule.

Common situations: Developers cd into an application project (packaging jar) instead of the root aggregator directory of a multi-module build, then run the create goal.

Related errors


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