diff --git a/maven-core/src/main/java/org/apache/maven/internal/impl/DefaultLifecycleRegistry.java b/maven-core/src/main/java/org/apache/maven/internal/impl/DefaultLifecycleRegistry.java index 9ea3be92ecdc..b3c521a2948c 100644 --- a/maven-core/src/main/java/org/apache/maven/internal/impl/DefaultLifecycleRegistry.java +++ b/maven-core/src/main/java/org/apache/maven/internal/impl/DefaultLifecycleRegistry.java @@ -204,42 +204,71 @@ public String id() { @Override public Collection phases() { - return lifecycle.getPhases().stream() - .map(name -> (Phase) new Phase() { - @Override - public String name() { - return name; + List names = lifecycle.getPhases(); + List phases = new ArrayList<>(); + for (int i = 0; i < names.size(); i++) { + String name = names.get(i); + String prev = i > 0 ? names.get(i - 1) : null; + phases.add(new Phase() { + @Override + public String name() { + return name; + } + + @Override + public List phases() { + return List.of(); + } + + @Override + public Stream allPhases() { + return Stream.concat( + Stream.of(this), phases().stream().flatMap(Lifecycle.Phase::allPhases)); + } + + @Override + public List plugins() { + Map lfPhases = lifecycle.getDefaultLifecyclePhases(); + LifecyclePhase phase = lfPhases != null ? lfPhases.get(name) : null; + if (phase != null) { + Map plugins = new LinkedHashMap<>(); + DefaultPackagingRegistry.parseLifecyclePhaseDefinitions(plugins, name, phase); + return plugins.values().stream().toList(); } + return List.of(); + } - @Override - public List phases() { + @Override + public Collection links() { + if (prev == null) { return List.of(); + } else { + return List.of(new Link() { + @Override + public Kind kind() { + return Kind.AFTER; + } + + @Override + public Pointer pointer() { + return new Pointer() { + @Override + public String phase() { + return prev; + } + + @Override + public Type type() { + return Type.PROJECT; + } + }; + } + }); } - - @Override - public Stream allPhases() { - return Stream.concat( - Stream.of(this), phases().stream().flatMap(Lifecycle.Phase::allPhases)); - } - - @Override - public List plugins() { - Map lfPhases = lifecycle.getDefaultLifecyclePhases(); - LifecyclePhase phase = lfPhases != null ? lfPhases.get(name) : null; - if (phase != null) { - Map plugins = new LinkedHashMap<>(); - DefaultPackagingRegistry.parseLifecyclePhaseDefinitions(plugins, name, phase); - return plugins.values().stream().toList(); - } - return List.of(); - } - - @Override - public Collection links() { - return List.of(); - } - }) - .toList(); + } + }); + } + return phases; } @Override