apache/maven · error · DuplicateProjectException
Two or more projects in the reactor have the same identifier
Error message
Two or more projects in the reactor have the same identifier, please make sure that <groupId>:<artifactId>:<version> is unique for each project: {} What it means
While collecting the reactor project index, DefaultMaven groups projects by groupId:artifactId:version and throws DuplicateProjectException when two or more reactor projects share the same GAV; the message prints the collisions map (GAV -> list of offending pom files). Reactor identity must be unique because dependency resolution inside the session keys on it.
Source
Thrown at impl/maven-core/src/main/java/org/apache/maven/DefaultMaven.java:633
MavenProject collision = index.get(projectId);
if (collision == null) {
index.put(projectId, project);
} else {
List<File> pomFiles = collisions.get(projectId);
if (pomFiles == null) {
pomFiles = new ArrayList<>(Arrays.asList(collision.getFile(), project.getFile()));
collisions.put(projectId, pomFiles);
} else {
pomFiles.add(project.getFile());
}
}
}
if (!collisions.isEmpty()) {
throw new DuplicateProjectException(
"Two or more projects in the reactor"
+ " have the same identifier, please make sure that <groupId>:<artifactId>:<version>"
+ " is unique for each project: " + collisions,
collisions);
}
return index;
}
private Result<? extends ProjectDependencyGraph> buildGraph(MavenSession session) {
Result<? extends ProjectDependencyGraph> graphResult = graphBuilder.build(session);
for (ModelProblem problem : graphResult.getProblems()) {
if (problem.getSeverity() == ModelProblem.Severity.WARNING) {
logger.warn(problem.getMessage());
} else {
logger.error(problem.getMessage());
}
}View on GitHub (pinned to e4093d4e12)
Solutions
- Read the message: it lists each duplicated GAV and every pom file involved - open those poms.
- Make each module's artifactId (or version) unique, or remove the duplicate/overlapping `<module>` entry.
- Check `<modules>` in all profiles for the same path twice; normalize relative paths (drop `./`).
- Ensure child modules declare their own artifactId instead of inheriting the parent's.
- Run `mvn validate` after restructuring to confirm the reactor is unique.
Example fix
<!-- before: same module reachable twice --> <modules> <module>app</module> <module>./app</module> </modules> <!-- after --> <modules> <module>app</module> </modules>
Defensive patterns
Strategy: try-catch
Try / catch
try {
MavenExecutionResult result = maven.execute(request);
for (Throwable t : result.getExceptions()) {
if (t instanceof DuplicateProjectException dpe) {
// dpe.getCollisions() maps GAV -> offending pom files
reportDuplicateProjects(dpe.getCollisions());
}
}
} catch (DuplicateProjectException dpe) {
reportDuplicateProjects(dpe.getCollisions());
} Prevention
- Lint aggregator POMs for duplicate module paths and duplicate child GAVs in CI.
- Always set an explicit artifactId in child modules.
- Normalize module paths (no `./` prefixes) to avoid accidental double inclusion.
When it happens
Trigger: The same module reachable twice (e.g. `<module>app</module>` and `<module>./app</module>`); overlapping module paths across profiles; two submodules copy-pasted without changing artifactId; a child POM that fails to override the parent's artifactId.
Common situations: Copy-pasted module scaffolds; profile combinations only activated together in CI; restructured repos with stale `<module>` entries; aggregator POMs including a directory both directly and via a wildcard-ish path.
Related errors
- Project '{}' is duplicated in the reactor
- Edge between '{}' and '{}' introduces to cycle in the graph
- No unique Source for %s:%s: %s and %s
- Try running the build up to the lifecycle phase "package"
- {parameterName} has been declared multiple times in mojo wit
AI-assisted analysis of apache/maven@e4093d4e12 (2026-08-21).
Data as JSON: /api/errors/9abd4c01097e4903.
Report an issue: GitHub.