List of usage examples for org.apache.maven AbstractMavenLifecycleParticipant afterSessionStart
public void afterSessionStart(MavenSession session) throws MavenExecutionException
From source file:org.eclipse.che.maven.server.MavenServerImpl.java
License:Open Source License
public void runMavenRequest(MavenExecutionRequest request, Runnable runnable) { DefaultMaven maven = (DefaultMaven) getMavenComponent(Maven.class); RepositorySystemSession repositorySystemSession = maven.newRepositorySession(request); request.getProjectBuildingRequest().setRepositorySession(repositorySystemSession); MavenSession mavenSession = new MavenSession(container, repositorySystemSession, request, new DefaultMavenExecutionResult()); LegacySupport legacySupport = getMavenComponent(LegacySupport.class); MavenSession previousSession = legacySupport.getSession(); legacySupport.setSession(mavenSession); try {/*from w w w. j a v a 2 s .co m*/ for (AbstractMavenLifecycleParticipant participant : getLifecycleParticipants( Collections.emptyList())) { participant.afterSessionStart(mavenSession); } runnable.run(); } catch (MavenExecutionException e) { throw new RuntimeException(e); } finally { legacySupport.setSession(previousSession); } }
From source file:org.jetbrains.idea.maven.server.Maven30ServerEmbedderImpl.java
License:Apache License
public void executeWithMavenSession(MavenExecutionRequest request, Runnable runnable) { DefaultMaven maven = (DefaultMaven) getComponent(Maven.class); RepositorySystemSession repositorySession = maven.newRepositorySession(request); request.getProjectBuildingRequest().setRepositorySession(repositorySession); MavenSession mavenSession = new MavenSession(myContainer, repositorySession, request, new DefaultMavenExecutionResult()); LegacySupport legacySupport = getComponent(LegacySupport.class); MavenSession oldSession = legacySupport.getSession(); legacySupport.setSession(mavenSession); /** adapted from {@link DefaultMaven#doExecute(MavenExecutionRequest)} */ try {/* w w w .j av a 2 s.c o m*/ for (AbstractMavenLifecycleParticipant listener : getLifecycleParticipants( Collections.<MavenProject>emptyList())) { listener.afterSessionStart(mavenSession); } } catch (MavenExecutionException e) { throw new RuntimeException(e); } try { runnable.run(); } finally { legacySupport.setSession(oldSession); } }