{"record":{"id":"fe6853db5df28ee6","repo":"apache/maven","slug":"project-is-duplicated-in-the-reactor","errorCode":null,"errorMessage":"Project '{}' is duplicated in the reactor","messagePattern":"Project '(.+?)' is duplicated in the reactor","errorType":"exception","errorClass":"DuplicateProjectException","httpStatus":null,"severity":"error","filePath":"impl/maven-core/src/main/java/org/apache/maven/project/ProjectSorter.java","lineNumber":84,"sourceCode":"    // In this case, both the verify and the report goals are called\n    // in a different lifecycle. Though the compiler-plugin has a valid use case, although\n    // that seems to work fine. We need to take versions and lifecycle into account.\n    public ProjectSorter(Collection<MavenProject> projects) throws CycleDetectedException, DuplicateProjectException {\n        graph = new Graph();\n\n        // groupId:artifactId:version -> project\n        projectMap = new HashMap<>(projects.size() * 2);\n\n        // groupId:artifactId -> (version -> vertex)\n        Map<String, Map<String, Vertex>> vertexMap = new HashMap<>(projects.size() * 2);\n\n        for (MavenProject project : projects) {\n            String projectId = getId(project);\n\n            MavenProject conflictingProject = projectMap.put(projectId, project);\n\n            if (conflictingProject != null) {\n                throw new DuplicateProjectException(\n                        projectId,\n                        conflictingProject.getFile(),\n                        project.getFile(),\n                        \"Project '\" + projectId + \"' is duplicated in the reactor\");\n            }\n\n            String projectKey = ArtifactUtils.versionlessKey(project.getGroupId(), project.getArtifactId());\n\n            Map<String, Vertex> vertices = vertexMap.computeIfAbsent(projectKey, k -> new HashMap<>(2, 1));\n\n            vertices.put(project.getVersion(), graph.addVertex(projectId));\n        }\n\n        for (Vertex projectVertex : graph.getVertices()) {\n            String projectId = projectVertex.getLabel();\n\n            MavenProject project = projectMap.get(projectId);\n","sourceCodeStart":66,"sourceCodeEnd":102,"githubUrl":"https://github.com/apache/maven/blob/e4093d4e120eac99d6bdce5ba67cace2f3085c97/impl/maven-core/src/main/java/org/apache/maven/project/ProjectSorter.java#L66-L102","documentation":"ProjectSorter turns a multi-module build's project list into a DAG for reactor ordering. It keys every module by its full coordinates groupId:artifactId:version and throws DuplicateProjectException when a second project maps to the same id, because one GAV must identify exactly one vertex in the graph.","triggerScenarios":"Calling new ProjectSorter(projects) (directly or via reactor/session setup) with two MavenProject instances sharing groupId, artifactId and version: the same module directory listed twice in <modules>, or two different directories whose POMs declare identical coordinates.","commonSituations":"Copy-pasted module POMs where <artifactId> was never changed; the same module included by both the parent <modules> list and an active profile; aggregate POMs re-including an already-built submodule; version overrides that make two modules collide.","solutions":["Read the projectId named in the exception (groupId:artifactId:version) and grep all pom.xml files for that artifactId to locate the colliding modules","Give each colliding module a unique <artifactId> or a different <version>","Remove the duplicated <module> entry or the profile inclusion that adds the same project twice","If the same project must feed several builds, build it once and consume it as a normal dependency"],"exampleFix":"<!-- before -->\n<modules>\n  <module>api</module>\n  <module>api</module>   <!-- duplicated entry -->\n  <module>app</module>\n</modules>\n\n<!-- after -->\n<modules>\n  <module>api</module>\n  <module>app</module>\n</modules>","handlingStrategy":"try-catch","validationCode":"Map<String, MavenProject> seen = new HashMap<>();\nfor (MavenProject p : projects) {\n    String id = p.getGroupId() + \":\" + p.getArtifactId() + \":\" + p.getVersion();\n    if (seen.put(id, p) != null) {\n        throw new IllegalArgumentException(\"Duplicate reactor project: \" + id);\n    }\n}\nnew ProjectSorter(projects);","typeGuard":null,"tryCatchPattern":"try {\n    ProjectSorter sorter = new ProjectSorter(projects);\n} catch (DuplicateProjectException e) {\n    // e.getProjectId() names the colliding groupId:artifactId:version\n    throw new BuildFailure(\"duplicate module \" + e.getProjectId(), e);\n}","preventionTips":["Keep one <module> entry per directory","Give every module in a reactor a unique artifactId and inherit <version> from the parent","Run mvn validate after restructuring a multi-module tree to surface sorting errors early"],"tags":["maven","reactor","multi-module","duplicate","graph"],"backgroundTag":"duplicate-module-in-reactor","analyzedSha":"e4093d4e120eac99d6bdce5ba67cace2f3085c97","analyzedAt":"2026-08-21T22:58:24.034Z","schemaVersion":2},"datasetVersion":"2026-08-21T23:17:16.201Z"}