Collection<AbstractMavenLifecycleParticipant> (Collection<MavenProject> projects) { Collection<AbstractMavenLifecycleParticipant> lifecycleListeners = new LinkedHashSet<>(); ClassLoader originalClassLoader = Thread.currentThread().getContextClassLoader(); try { try { lifecycleListeners.addAll(getContainer().lookupList(AbstractMavenLifecycleParticipant.class)); } catch (ComponentLookupException e) { // this is just silly, lookupList should return an empty list! warn("Failed to lookup lifecycle participants", e); } Collection<ClassLoader> scannedRealms = new HashSet<>(); for (MavenProject project : projects) { ClassLoader projectRealm = project.getClassRealm(); if (projectRealm != null && scannedRealms.add(projectRealm)) { Thread.currentThread().setContextClassLoader(projectRealm); try { lifecycleListeners.addAll(getContainer().lookupList(AbstractMavenLifecycleParticipant.class)); } catch (ComponentLookupException e) { // this is just silly, lookupList should return an empty list! warn("Failed to lookup lifecycle participants", e); } } } } finally { Thread.currentThread().setContextClassLoader(originalClassLoader); } return lifecycleListeners; }