[ https://issues.apache.org/jira/browse/MNG-8123?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17848130#comment-17848130 ]
ASF GitHub Bot commented on MNG-8123: ------------------------------------- gnodet commented on code in PR #1524: URL: https://github.com/apache/maven/pull/1524#discussion_r1607989007 ########## 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: Actually, I can't use the instance to detect, as getting the instance will cause the lookup error: the map is lazily managed by sisu, and the instance is created when requested only, but that's what causes the lookup error. > Maven 4.0.0-beta-2 fails with maven-build-cache-extension 1.2.0 > --------------------------------------------------------------- > > Key: MNG-8123 > URL: https://issues.apache.org/jira/browse/MNG-8123 > Project: Maven > Issue Type: Bug > Affects Versions: 4.0.0-beta-2 > Reporter: Filipe Roque > Priority: Major > Fix For: 4.0.0-beta-3 > > > {code:java} > ❯ mvn --version > Apache Maven 4.0.0-beta-2 (828faba81940a8d2f2e5cfab6f60e35d1ab61ca0) > Maven home: /opt/maven/apache-maven-4.0.0-beta-2 > Java version: 22.0.1, vendor: Eclipse Adoptium, runtime: > /usr/lib/jvm/temurin-22-jdk-amd64 > Default locale: en_US, platform encoding: UTF-8 > OS name: "linux", version: "6.5.0-28-generic", arch: "amd64", family: "unix" > {code} > project created with > {code:java} > mvn archetype:generate {code} > Adding maven cache extension > {code:java} > cat .mvn/extensions.xml > <extensions xmlns="http://maven.apache.org/EXTENSIONS/1.0.0"> > <extension> > <groupId>org.apache.maven.extensions</groupId> > <artifactId>maven-build-cache-extension</artifactId> > <version>1.2.0</version> > </extension> > </extensions> > {code} > Fails with: > {code:java} > ❯ mvn compile [INFO] Cache configuration is not available at configured path > /home/froque/workspace/testes/project1/.mvn/maven-build-cache-config.xml, > cache is enabled with defaults [INFO] Using XX hash algorithm for cache > [ERROR] Internal error: com.google.inject.ProvisionException: Unable to > provision, see the following errors: [ERROR] [ERROR] 1) > [Guice/NullInjectedIntoNonNullable]: null returned by binding at > LocatorWiring [ERROR] but the 3rd parameter of > LifecyclePhasesHelper.<init>(LifecyclePhasesHelper.java:61) is not @Nullable > [ERROR] at LocatorWiring [ERROR] at > LifecyclePhasesHelper.<init>(LifecyclePhasesHelper.java:61) [ERROR] \_ > for 3rd parameter [ERROR] at > ClassRealm[coreExtension>org.apache.maven.extensions:maven-build-cache-extension:1.2.0, > parent: ClassRealm[plexus.core, parent: null]] [ERROR] \_ installed > by: WireModule -> PlexusBindingModule [ERROR] at > CacheControllerImpl.<init>(CacheControllerImpl.java:156) [ERROR] \_ for > 10th parameter [ERROR] at > ClassRealm[coreExtension>org.apache.maven.extensions:maven-build-cache-extension:1.2.0, > parent: ClassRealm[plexus.core, parent: null]] [ERROR] \_ installed > by: WireModule -> PlexusBindingModule [ERROR] while locating > CacheControllerImpl [ERROR] while locating Object annotated with * [ERROR] > at LocatorWiring [ERROR] at > CacheLifecycleParticipant.<init>(CacheLifecycleParticipant.java:39) [ERROR] > \_ for 2nd parameter [ERROR] at > ClassRealm[coreExtension>org.apache.maven.extensions:maven-build-cache-extension:1.2.0, > parent: ClassRealm[plexus.core, parent: null]] [ERROR] \_ installed > by: WireModule -> PlexusBindingModule [ERROR] while locating > CacheLifecycleParticipant [ERROR] while locating Object annotated with * > [ERROR] [ERROR] Learn more: [ERROR] > https://github.com/google/guice/wiki/NULL_INJECTED_INTO_NON_NULLABLE [ERROR] > [ERROR] 1 error [ERROR] [ERROR] ====================== [ERROR] Full > classname legend: [ERROR] ====================== [ERROR] CacheControllerImpl: > "org.apache.maven.buildcache.CacheControllerImpl" [ERROR] > CacheLifecycleParticipant: > "org.apache.maven.buildcache.CacheLifecycleParticipant" [ERROR] > LifecyclePhasesHelper: > "org.apache.maven.buildcache.LifecyclePhasesHelper" [ERROR] LocatorWiring: > "org.eclipse.sisu.wire.LocatorWiring" [ERROR] PlexusBindingModule: > "org.eclipse.sisu.plexus.PlexusBindingModule" [ERROR] WireModule: > "org.eclipse.sisu.wire.WireModule" [ERROR] ======================== > [ERROR] End of classname legend: [ERROR] ======================== [ERROR] -> > [Help 1] org.apache.maven.InternalErrorException: Internal error: > com.google.inject.ProvisionException: Unable to provision, see the following > errors:1) [Guice/NullInjectedIntoNonNullable]: null returned by binding at > LocatorWiring but the 3rd parameter of > LifecyclePhasesHelper.<init>(LifecyclePhasesHelper.java:61) is not @Nullable > at LocatorWiring at > LifecyclePhasesHelper.<init>(LifecyclePhasesHelper.java:61) \_ for 3rd > parameter at > ClassRealm[coreExtension>org.apache.maven.extensions:maven-build-cache-extension:1.2.0, > parent: ClassRealm[plexus.core, parent: null]] \_ installed by: > WireModule -> PlexusBindingModule at > CacheControllerImpl.<init>(CacheControllerImpl.java:156) \_ for 10th > parameter at > ClassRealm[coreExtension>org.apache.maven.extensions:maven-build-cache-extension:1.2.0, > parent: ClassRealm[plexus.core, parent: null]] \_ installed by: > WireModule -> PlexusBindingModule while locating CacheControllerImpl > while locating Object annotated with * at LocatorWiring at > CacheLifecycleParticipant.<init>(CacheLifecycleParticipant.java:39) \_ > for 2nd parameter at > ClassRealm[coreExtension>org.apache.maven.extensions:maven-build-cache-extension:1.2.0, > parent: ClassRealm[plexus.core, parent: null]] \_ installed by: > WireModule -> PlexusBindingModule while locating CacheLifecycleParticipant > while locating Object annotated with *Learn more: > https://github.com/google/guice/wiki/NULL_INJECTED_INTO_NON_NULLABLE1 > error====================== Full classname legend: ====================== > CacheControllerImpl: "org.apache.maven.buildcache.CacheControllerImpl" > CacheLifecycleParticipant: > "org.apache.maven.buildcache.CacheLifecycleParticipant" > LifecyclePhasesHelper: > "org.apache.maven.buildcache.LifecyclePhasesHelper" LocatorWiring: > "org.eclipse.sisu.wire.LocatorWiring" PlexusBindingModule: > "org.eclipse.sisu.plexus.PlexusBindingModule" WireModule: > "org.eclipse.sisu.wire.WireModule" ======================== End of classname > legend: ======================== at > org.apache.maven.DefaultMaven.execute(DefaultMaven.java:157) at > org.apache.maven.cli.MavenCli.execute(MavenCli.java:958) at > org.apache.maven.cli.MavenCli.doMain(MavenCli.java:288) at > org.apache.maven.cli.MavenCli.main(MavenCli.java:205) at > jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:103) > at java.lang.reflect.Method.invoke(Method.java:580) at > org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:282) > at > org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:225) > at > org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:406) > at > org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:347) > Caused by: com.google.inject.ProvisionException: Unable to provision, see the > following errors:1) [Guice/NullInjectedIntoNonNullable]: null returned by > binding at LocatorWiring but the 3rd parameter of > LifecyclePhasesHelper.<init>(LifecyclePhasesHelper.java:61) is not @Nullable > at LocatorWiring at > LifecyclePhasesHelper.<init>(LifecyclePhasesHelper.java:61) \_ for 3rd > parameter at > ClassRealm[coreExtension>org.apache.maven.extensions:maven-build-cache-extension:1.2.0, > parent: ClassRealm[plexus.core, parent: null]] \_ installed by: > WireModule -> PlexusBindingModule at > CacheControllerImpl.<init>(CacheControllerImpl.java:156) \_ for 10th > parameter at > ClassRealm[coreExtension>org.apache.maven.extensions:maven-build-cache-extension:1.2.0, > parent: ClassRealm[plexus.core, parent: null]] \_ installed by: > WireModule -> PlexusBindingModule while locating CacheControllerImpl > while locating Object annotated with * at LocatorWiring at > CacheLifecycleParticipant.<init>(CacheLifecycleParticipant.java:39) \_ > for 2nd parameter at > ClassRealm[coreExtension>org.apache.maven.extensions:maven-build-cache-extension:1.2.0, > parent: ClassRealm[plexus.core, parent: null]] \_ installed by: > WireModule -> PlexusBindingModule while locating CacheLifecycleParticipant > while locating Object annotated with *Learn more: > https://github.com/google/guice/wiki/NULL_INJECTED_INTO_NON_NULLABLE1 > error====================== Full classname legend: ====================== > CacheControllerImpl: "org.apache.maven.buildcache.CacheControllerImpl" > CacheLifecycleParticipant: > "org.apache.maven.buildcache.CacheLifecycleParticipant" > LifecyclePhasesHelper: > "org.apache.maven.buildcache.LifecyclePhasesHelper" LocatorWiring: > "org.eclipse.sisu.wire.LocatorWiring" PlexusBindingModule: > "org.eclipse.sisu.plexus.PlexusBindingModule" WireModule: > "org.eclipse.sisu.wire.WireModule" ======================== End of classname > legend: ======================== at > com.google.inject.internal.InternalProvisionException.toProvisionException(InternalProvisionException.java:251) > at com.google.inject.internal.InjectorImpl$1.get(InjectorImpl.java:1151) > at org.eclipse.sisu.inject.Guice4$2.get(Guice4.java:233) at > org.eclipse.sisu.inject.LazyBeanEntry.getValue(LazyBeanEntry.java:81) at > org.eclipse.sisu.plexus.LazyPlexusBean.getValue(LazyPlexusBean.java:51) > at > org.eclipse.sisu.wire.EntryListAdapter$ValueIterator.next(EntryListAdapter.java:111) > at java.util.AbstractCollection.addAll(AbstractCollection.java:337) > at > org.apache.maven.DefaultMaven.getExtensionComponents(DefaultMaven.java:436) > at org.apache.maven.DefaultMaven.callListeners(DefaultMaven.java:375) > at org.apache.maven.DefaultMaven.afterSessionStart(DefaultMaven.java:355) > at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:237) at > org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:225) at > org.apache.maven.DefaultMaven.execute(DefaultMaven.java:149) at > org.apache.maven.cli.MavenCli.execute(MavenCli.java:958) at > org.apache.maven.cli.MavenCli.doMain(MavenCli.java:288) at > org.apache.maven.cli.MavenCli.main(MavenCli.java:205) at > jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:103) > at java.lang.reflect.Method.invoke(Method.java:580) at > org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:282) > at > org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:225) > at > org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:406) > at > org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:347) > [ERROR] [ERROR] To see the full stack trace of the errors, re-run Maven with > the '-e' switch [ERROR] Re-run Maven using the '-X' switch to enable verbose > output [ERROR] [ERROR] For more information about the errors and possible > solutions, please read the following articles: [ERROR] [Help 1] > http://cwiki.apache.org/confluence/display/MAVEN/InternalErrorException > {code} > Maven 4.0.0-alpha-13 does not fail: > {code} > ❯ /opt/maven/apache-maven-4.0.0-alpha-13/bin/mvn -q compile > {code} -- This message was sent by Atlassian Jira (v8.20.10#820010)