{"record":{"id":"9026a3dde4b87ef5","repo":"quarkusio/quarkus","slug":"you-are-trying-to-create-a-maven-project-in-a-dire","errorCode":null,"errorMessage":"You are trying to create a Maven project in a directory that contains only Gradle build files.","messagePattern":"You are trying to create a Maven project in a directory that contains only Gradle build files\\.","errorType":"exception","errorClass":"MojoExecutionException","httpStatus":null,"severity":"error","filePath":"devtools/maven/src/main/java/io/quarkus/maven/CreateProjectMojo.java","lineNumber":278,"sourceCode":"        if (buildToolEnum == null) {\n            String validBuildTools = String.join(\",\",\n                    Arrays.asList(BuildTool.values()).stream().map(BuildTool::toString).collect(Collectors.toList()));\n            throw new IllegalArgumentException(\"Choose a valid build tool. Accepted values are: \" + validBuildTools);\n        }\n        if (BuildTool.MAVEN.equals(buildToolEnum)) {\n            if (pom != null && pom.isFile()) {\n                try {\n                    parentPomModel = MojoUtils.readPom(pom);\n                    if (!\"pom\".equals(parentPomModel.getPackaging())) {\n                        throw new MojoExecutionException(\n                                \"The parent project must have a packaging type of POM. Current packaging: \"\n                                        + parentPomModel.getPackaging());\n                    }\n                } catch (IOException e) {\n                    throw new MojoExecutionException(\"Could not access parent pom.\", e);\n                }\n            } else if (containsAtLeastOneGradleFile) {\n                throw new MojoExecutionException(\n                        \"You are trying to create a Maven project in a directory that contains only Gradle build files.\");\n            }\n        } else if (BuildTool.GRADLE.equals(buildToolEnum) || BuildTool.GRADLE_KOTLIN_DSL.equals(buildToolEnum)) {\n            if (containsAtLeastOneGradleFile) {\n                throw new MojoExecutionException(\"Adding subprojects to gradle projects is not implemented.\");\n            } else if (pom != null && pom.isFile()) {\n                throw new MojoExecutionException(\n                        \"You are trying to create gradle project in a directory that contains only maven build files.\");\n            }\n        }\n\n        askTheUserForMissingValues();\n        if (!DEFAULT_ARTIFACT_ID.equals(projectArtifactId) && !OK_ID.matcher(projectArtifactId).matches()) {\n            throw new MojoExecutionException(String.format(BAD_IDENTIFIER, \"artifactId\", projectArtifactId));\n        }\n        if (!DEFAULT_GROUP_ID.equals(projectGroupId) && !OK_ID.matcher(projectGroupId).matches()) {\n            throw new MojoExecutionException(String.format(BAD_IDENTIFIER, \"groupId\", projectGroupId));\n        }","sourceCodeStart":260,"sourceCodeEnd":296,"githubUrl":"https://github.com/quarkusio/quarkus/blob/e1c734241f34c7919086ceb4c9262b4a58f6de44/devtools/maven/src/main/java/io/quarkus/maven/CreateProjectMojo.java#L260-L296","documentation":"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.","triggerScenarios":"Running `mvn quarkus:create` (or create with -DbuildTool=maven) in a directory that has Gradle files but no pom.xml.","commonSituations":"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.","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"],"exampleFix":"// before\nmvn quarkus:create -DbuildTool=maven   # run inside a Gradle-only dir\n// after\nmvn quarkus:create -DbuildTool=gradle  # in an empty parent directory","handlingStrategy":"validation","validationCode":"boolean gradleOnly = Stream.of(\"build.gradle\",\"settings.gradle\",\"build.gradle.kts\",\"settings.gradle.kts\")\n        .anyMatch(n -> new File(dir, n).isFile());\nboolean hasPom = new File(dir, \"pom.xml\").isFile();\nif (buildTool.equals(\"maven\") && gradleOnly && !hasPom) throw new IllegalStateException(\"Gradle-only directory\");","typeGuard":null,"tryCatchPattern":"try {\n    runCreateGoal();\n} catch (MojoExecutionException e) {\n    if (e.getMessage().contains(\"directory that contains only Gradle build files\")) {\n        // rerun with -DbuildTool=gradle in an empty dir, or move to a Maven dir\n    }\n}","preventionTips":["Match -DbuildTool to the existing build files in the target directory","Generate into a fresh empty directory","Check directory contents before scripted create runs"],"tags":["build-tool","gradle","maven","conflict"],"backgroundTag":"build-tool-mismatch","analyzedSha":"e1c734241f34c7919086ceb4c9262b4a58f6de44","analyzedAt":"2026-09-05T17:01:29.979Z","contentChangedAt":"2026-09-05T17:01:29.979Z","schemaVersion":2},"datasetVersion":"2026-09-12T22:17:10.623Z"}