gnodet commented on code in PR #1524: URL: https://github.com/apache/maven/pull/1524#discussion_r1607983615
########## maven-core/src/main/java/org/apache/maven/internal/impl/DefaultLifecycleRegistry.java: ########## @@ -78,37 +83,44 @@ public DefaultLifecycleRegistry( @Override public Iterator<Lifecycle> iterator() { - return values.values().iterator(); + return stream().toList().iterator(); } @Override public Stream<Lifecycle> stream() { - return values.values().stream(); - } - - static <T> List<T> concat(List<T> l, T t) { - List<T> nl = new ArrayList<>(l.size() + 1); - nl.addAll(l); - nl.add(t); - return nl; + return providers.stream().map(ExtensibleEnumProvider::provides).flatMap(Collection::stream); } @Override - public List<String> computePhases(Lifecycle lifecycle) { - return lifecycle.phases().stream().map(Lifecycle.Phase::name).toList(); + public Optional<Lifecycle> lookup(String id) { + return Optional.empty(); } - static class LifecycleWrapperProvider implements LifecycleProvider { - private final Map<String, org.apache.maven.lifecycle.Lifecycle> lifecycles; + @Named + @Singleton + public static class LifecycleWrapperProvider implements LifecycleProvider { + private final PlexusContainer container; @Inject - LifecycleWrapperProvider(Map<String, org.apache.maven.lifecycle.Lifecycle> lifecycles) { - this.lifecycles = lifecycles; + public LifecycleWrapperProvider(PlexusContainer container) { + this.container = container; } @Override public Collection<Lifecycle> provides() { - return lifecycles.values().stream().map(this::wrap).collect(Collectors.toList()); + try { + Map<String, org.apache.maven.lifecycle.Lifecycle> all = + container.lookupMap(org.apache.maven.lifecycle.Lifecycle.class); + return all.keySet().stream() + .filter(id -> !Lifecycle.CLEAN.equals(id) Review Comment: We have a kind of chicken/egg situation. Lifecycle can be published by maven 3 extensions, but lifecycles must also be provided through the Maven 3 API. We must avoid rewrapping in a kind of loop the default lifecycles exposed using the maven 4 API because it leads to a lookup error (we end-up with a bean creation cycle). I can see if there's a better way, such as adding a new sub-interface `WrappedLifecycle` to better detect where the lifecycle come from (Maven 3 or 4 api and only wrap if for the other side). -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: issues-unsubscr...@maven.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org