quarkusio/quarkus · error · MojoExecutionException
You are trying to create a Maven project in a directory that
Error message
You are trying to create a Maven project in a directory that contains only Gradle build files.
What it means
When the create goal is asked to scaffold a Maven project (buildTool=maven) but the target directory contains only Gradle build files (build.gradle, settings.gradle, build.gradle.kts, settings.gradle.kts) and no pom.xml, the mojo refuses to proceed. Mixing build systems in one directory would produce a broken project, so it fails fast with this message.
Source
Thrown at devtools/maven/src/main/java/io/quarkus/maven/CreateProjectMojo.java:278
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.");
}
}
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));
}View on GitHub (pinned to e1c734241f)
Solutions
- Run the goal with `-DbuildTool=gradle` (or gradle-kotlin-dsl) to match the directory, creating the project in a separate empty directory first
- Create the project in a fresh empty directory and move it into a Gradle multi-module setup manually
- Remove/rename the Gradle files if they are leftovers and a Maven project is genuinely intended
Example fix
// before mvn quarkus:create -DbuildTool=maven # run inside a Gradle-only dir // after mvn quarkus:create -DbuildTool=gradle # in an empty parent directory
Defensive patterns
Strategy: validation
Validate before calling
boolean gradleOnly = Stream.of("build.gradle","settings.gradle","build.gradle.kts","settings.gradle.kts")
.anyMatch(n -> new File(dir, n).isFile());
boolean hasPom = new File(dir, "pom.xml").isFile();
if (buildTool.equals("maven") && gradleOnly && !hasPom) throw new IllegalStateException("Gradle-only directory"); Try / catch
try {
runCreateGoal();
} catch (MojoExecutionException e) {
if (e.getMessage().contains("directory that contains only Gradle build files")) {
// rerun with -DbuildTool=gradle in an empty dir, or move to a Maven dir
}
} Prevention
- Match -DbuildTool to the existing build files in the target directory
- Generate into a fresh empty directory
- Check directory contents before scripted create runs
When it happens
Trigger: Running `mvn quarkus:create` (or create with -DbuildTool=maven) in a directory that has Gradle files but no pom.xml.
Common situations: Trying to add a Quarkus module inside an existing Gradle project using the Maven plugin, or cd-ing into a Gradle workspace directory out of habit.
Related errors
- You are trying to create gradle Project in a directory that
- Quarkus Gradle plugins require Gradle
- Could not resolve POM for
- Unable to add extensions
- Failed to initialize Maven artifact resolver
AI-assisted analysis of quarkusio/quarkus@e1c734241f (2026-09-05).
Data as JSON: /api/errors/9026a3dde4b87ef5.
Report an issue: GitHub.