quarkusio/quarkus · error · MojoExecutionException

${BAD_IDENTIFIER formatted with 'artifactId' and projectArti

Error message

${BAD_IDENTIFIER formatted with 'artifactId' and projectArtifactId}

What it means

After prompting for any missing values, the mojo validates the project artifactId against the OK_ID regex (a valid Maven/Java identifier pattern). If the user-supplied artifactId differs from the default and does not match, it throws a MojoExecutionException with the BAD_IDENTIFIER template formatted with 'artifactId' and the offending value. Maven identifiers cannot contain spaces, special characters, or start with invalid characters.

Source

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

                } 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.");
            }
        }

        askTheUserForMissingValues();
        if (!DEFAULT_ARTIFACT_ID.equals(projectArtifactId) && !OK_ID.matcher(projectArtifactId).matches()) {
            throw new MojoExecutionException(String.format(BAD_IDENTIFIER, "artifactId", projectArtifactId));
        }
        if (!DEFAULT_GROUP_ID.equals(projectGroupId) && !OK_ID.matcher(projectGroupId).matches()) {
            throw new MojoExecutionException(String.format(BAD_IDENTIFIER, "groupId", projectGroupId));
        }

        projectRoot = new File(outputDirectory, projectArtifactId);
        if (projectRoot.exists()) {
            throw new MojoExecutionException("Unable to create the project, " +
                    "the directory " + projectRoot.getAbsolutePath() + " already exists");
        }

        boolean success;
        final Path projectDirPath = projectRoot.toPath();
        try {
            extensions = CreateProjectHelper.sanitizeExtensions(extensions);
            catalog = CreateProjectHelper.completeCatalog(catalog, extensions, mvn);
            sanitizeOptions();

View on GitHub (pinned to e1c734241f)

Solutions

  1. Use a lowercase alphanumeric artifactId with hyphens only, e.g. -DprojectArtifactId=my-app
  2. Re-run without the flag and accept the default, or fix at the interactive prompt
  3. Sanitize the name in scripts before passing it (strip spaces/special characters)

Example fix

// before
mvn quarkus:create -DprojectArtifactId="My App!"
// after
mvn quarkus:create -DprojectArtifactId=my-app
Defensive patterns

Strategy: validation

Validate before calling

Pattern OK_ID = Pattern.compile("^[a-zA-Z][a-zA-Z0-9_-]*$");
if (!OK_ID.matcher(artifactId).matches()) throw new IllegalArgumentException("Invalid artifactId: " + artifactId);

Try / catch

try {
    runCreateGoal();
} catch (MojoExecutionException e) {
    if (e.getMessage().contains("artifactId")) {
        // retry with a sanitized identifier
    }
}

Prevention

When it happens

Trigger: `mvn quarkus:create -DprojectArtifactId="my app!"` or typing an invalid artifactId at the interactive prompt.

Common situations: Artifact IDs with spaces, slashes, uppercase-with-symbols, trailing hyphens, or pasted paths pasted as the artifactId; scripts interpolating unvalidated names.

Related errors


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