quarkusio/quarkus · error · MojoExecutionException
Adding subprojects to gradle projects is not implemented.
Error message
Adding subprojects to gradle projects is not implemented.
What it means
The create goal supports scaffolding Gradle projects only as brand-new roots; adding a new Gradle subproject to an existing Gradle build is not implemented. If the target directory already contains Gradle build files and the selected build tool is gradle (or gradle-kotlin-dsl), the mojo throws this MojoExecutionException instead of attempting a partial subproject generation.
Source
Thrown at devtools/maven/src/main/java/io/quarkus/maven/CreateProjectMojo.java:283
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));
}
projectRoot = new File(outputDirectory, projectArtifactId);
if (projectRoot.exists()) {
throw new MojoExecutionException("Unable to create the project, " +
"the directory " + projectRoot.getAbsolutePath() + " already exists");View on GitHub (pinned to e1c734241f)
Solutions
- Generate the Gradle project in a fresh empty directory, then integrate it as a subproject manually (add `include` to settings.gradle, set its parent)
- Hand-write the Gradle subproject build file against the Quarkus Gradle plugin documentation
- Use code.quarkus.io to generate the project separately and copy it in
Example fix
// before: settings.gradle of parent, expecting plugin to edit it // (plugin refuses; must be done manually) include 'app' // after: generate in empty dir, then add manually in parent settings.gradle include 'my-quarkus-app'
Defensive patterns
Strategy: validation
Validate before calling
boolean hasGradleFiles = Stream.of("build.gradle","settings.gradle","build.gradle.kts","settings.gradle.kts")
.anyMatch(n -> new File(dir, n).isFile());
if (buildTool.startsWith("gradle") && hasGradleFiles)
throw new IllegalStateException("Subproject generation not supported; use an empty directory"); Try / catch
try {
runCreateGoal();
} catch (MojoExecutionException e) {
if (e.getMessage().contains("Adding subprojects to gradle projects is not implemented")) {
// generate separately and wire into settings.gradle manually
}
} Prevention
- Only generate Gradle projects into empty directories
- Plan Quarkus subprojects by manual settings.gradle integration
- Document this limitation in team build scripts
When it happens
Trigger: Running `mvn quarkus:create -DbuildTool=gradle` in a directory that already contains build.gradle or settings.gradle files.
Common situations: Trying to add a Quarkus service as a module of an existing Gradle multi-project build; CI scripts re-running create in an existing Gradle checkout.
Related errors
- Failed to resolve ${appArtifact}
- Requested artifact ${appArtifact} does not match project ${g
- No platforms detected in the project
- Failed to determine the Quarkus core version for the project
- Failed to configure ${taskPath}: sourceSet ${sourceSet} has
AI-assisted analysis of quarkusio/quarkus@e1c734241f (2026-09-05).
Data as JSON: /api/errors/0fbaf166dc5ba133.
Report an issue: GitHub.