List of usage examples for org.apache.maven AbstractMavenLifecycleParticipant afterProjectsRead
public void afterProjectsRead(MavenSession session) throws MavenExecutionException
From source file:org.eclipse.che.maven.server.MavenServerImpl.java
License:Open Source License
private void loadExtensions(MavenProject project, List<Exception> exceptions) { ClassLoader currentClassLoader = Thread.currentThread().getContextClassLoader(); Collection<AbstractMavenLifecycleParticipant> participants = getLifecycleParticipants( Collections.singletonList(project)); if (!participants.isEmpty()) { LegacySupport legacySupport = getMavenComponent(LegacySupport.class); MavenSession session = legacySupport.getSession(); session.setCurrentProject(project); session.setProjects(Collections.singletonList(project)); for (AbstractMavenLifecycleParticipant participant : participants) { Thread.currentThread().setContextClassLoader(participant.getClass().getClassLoader()); try { participant.afterProjectsRead(session); } catch (MavenExecutionException e) { exceptions.add(e);//from ww w.ja va 2s .com } finally { Thread.currentThread().setContextClassLoader(currentClassLoader); } } } }
From source file:org.jetbrains.idea.maven.server.Maven30ServerEmbedderImpl.java
License:Apache License
/** * adapted from {@link DefaultMaven#doExecute(MavenExecutionRequest)} *//* w w w . j a v a2 s. c o m*/ private void loadExtensions(MavenProject project, List<Exception> exceptions) { ClassLoader originalClassLoader = Thread.currentThread().getContextClassLoader(); Collection<AbstractMavenLifecycleParticipant> lifecycleParticipants = getLifecycleParticipants( Arrays.asList(project)); if (!lifecycleParticipants.isEmpty()) { LegacySupport legacySupport = getComponent(LegacySupport.class); MavenSession session = legacySupport.getSession(); session.setCurrentProject(project); session.setProjects(Arrays.asList(project)); for (AbstractMavenLifecycleParticipant listener : lifecycleParticipants) { Thread.currentThread().setContextClassLoader(listener.getClass().getClassLoader()); try { listener.afterProjectsRead(session); } catch (MavenExecutionException e) { exceptions.add(e); } finally { Thread.currentThread().setContextClassLoader(originalClassLoader); } } } }