{"record":{"id":"9f1cf0b458f6262a","repo":"quarkusio/quarkus","slug":"you-are-trying-to-create-gradle-project-in-a-direc","errorCode":null,"errorMessage":"You are trying to create gradle Project in a directory that contains only maven build files.","messagePattern":"You are trying to create gradle Project in a directory that contains only maven build files\\.","errorType":"exception","errorClass":"MojoExecutionException","httpStatus":null,"severity":"error","filePath":"devtools/maven/src/main/java/io/quarkus/maven/CreateProjectMojo.java","lineNumber":285,"sourceCode":"                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        }\n\n        projectRoot = new File(outputDirectory, projectArtifactId);\n        if (projectRoot.exists()) {\n            throw new MojoExecutionException(\"Unable to create the project, \" +\n                    \"the directory \" + projectRoot.getAbsolutePath() + \" already exists\");\n        }\n","sourceCodeStart":267,"sourceCodeEnd":303,"githubUrl":"https://github.com/quarkusio/quarkus/blob/e1c734241f34c7919086ceb4c9262b4a58f6de44/devtools/maven/src/main/java/io/quarkus/maven/CreateProjectMojo.java#L267-L303","documentation":"The inverse of the Maven-vs-Gradle check: when the create goal is asked for a Gradle project (buildTool=gradle or gradle-kotlin-dsl) but the target directory contains a pom.xml and no Gradle files, the mojo throws this MojoExecutionException. It prevents nesting a Gradle build inside a Maven project directory.","triggerScenarios":"Running `mvn quarkus:create -DbuildTool=gradle` in a directory that already has a pom.xml (project != null, pom.isFile()).","commonSituations":"Choosing Gradle in a prompt or script while sitting inside a Maven multi-module checkout; accidentally mixing tool flags in CI.","solutions":["Create the Gradle project in an empty directory instead","Drop the -DbuildTool=gradle flag (or set it to maven) to match the existing Maven directory","Move out of the Maven project directory before generating a Gradle project"],"exampleFix":"// before\nmvn quarkus:create -DbuildTool=gradle   # inside dir with pom.xml\n// after\ncd /path/to/empty-dir && mvn quarkus:create -DbuildTool=gradle","handlingStrategy":"validation","validationCode":"boolean hasPom = new File(dir, \"pom.xml\").isFile();\nif (buildTool.startsWith(\"gradle\") && hasPom) throw new IllegalStateException(\"Maven-only directory; use an empty dir for Gradle\");","typeGuard":null,"tryCatchPattern":"try {\n    runCreateGoal();\n} catch (MojoExecutionException e) {\n    if (e.getMessage().contains(\"directory that contains only maven build files\")) {\n        // cd to an empty directory or drop -DbuildTool=gradle\n    }\n}","preventionTips":["Don't select Gradle while inside a Maven checkout","Keep create-goal scripts pinned to one build tool per directory","Verify pom.xml absence before Gradle scaffolding"],"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"}