Skip to content

Commit 93f7534

Browse files
committed
Replace raw RuntimeException on reactor cycle with ProjectBuildingException.
When a reactor dependency cycle is detected, wrap the underlying org.codehaus.plexus.util.dag.CycleDetectedException in a new ProjectCycleException and throw a checked ProjectBuildingException (as declared by ProjectBuilder) instead of a raw RuntimeException. Keep non-cycle model problems on the existing ProjectBuildingException(results) path.
1 parent 735fd50 commit 93f7534

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

impl/maven-core/src/main/java/org/apache/maven/project/DefaultProjectBuilder.java

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -492,10 +492,22 @@ List<ProjectBuildingResult> build(List<File> pomFiles, boolean recursive) throws
492492
.findAny()
493493
.orElse(null);
494494
if (cycle != null) {
495-
throw new RuntimeException(new ProjectCycleException(
495+
final CycleDetectedException cde = (CycleDetectedException) cycle.getException();
496+
497+
final ProjectCycleException pce = new ProjectCycleException(
498+
"The projects in the reactor contain a cyclic reference: " + cycle.getMessage(), cde);
499+
500+
// If you can resolve these from the problem/result, set them; otherwise leave null.
501+
final String projectId = null;
502+
final File pomFile = null;
503+
504+
throw new ProjectBuildingException(
505+
projectId,
496506
"The projects in the reactor contain a cyclic reference: " + cycle.getMessage(),
497-
(CycleDetectedException) cycle.getException()));
507+
pomFile,
508+
pce);
498509
}
510+
499511
throw new ProjectBuildingException(results);
500512
}
501513

0 commit comments

Comments
 (0)