List of usage examples for org.apache.maven.execution MavenSession MavenSession
@Deprecated
@SuppressWarnings("checkstyle:parameternumber")
public MavenSession(PlexusContainer container, Settings settings, ArtifactRepository localRepository,
EventDispatcher eventDispatcher, ReactorManager unused, List<String> goals, String executionRootDir,
Properties executionProperties, Date startTime)
From source file:org.nuxeo.build.maven.MavenEmbedder.java
License:Open Source License
public void execute(List<MavenProject> projects, List<?> goals, EventMonitor eventMonitor, TransferListener transferListener, Properties properties, File executionRootDirectory) throws CycleDetectedException, LifecycleExecutionException, BuildFailureException, DuplicateProjectException, MissingProjectException { ReactorManager rm = new ReactorManager(projects); EventDispatcher eventDispatcher = new DefaultEventDispatcher(); eventDispatcher.addEventMonitor(eventMonitor); // If this option is set the exception seems to be hidden ... // rm.setFailureBehavior( ReactorManager.FAIL_AT_END ); rm.setFailureBehavior(ReactorManager.FAIL_FAST); MavenSession session = new MavenSession(embedder.getContainer(), settings, localRepository, eventDispatcher, rm, goals, executionRootDirectory.getAbsolutePath(), properties, new Date()); session.setUsingPOMsFromFilesystem(true); if (transferListener != null) { wagonManager.setDownloadMonitor(transferListener); }/*from w w w . j a v a 2s .c o m*/ // ---------------------------------------------------------------------- // Maven should not be using system properties internally but because // it does for now I'll just take properties that are handed to me // and set them so that the plugin expression evaluator will work // as expected. // ---------------------------------------------------------------------- if (properties != null) { for (Iterator<?> i = properties.keySet().iterator(); i.hasNext();) { String key = (String) i.next(); String value = properties.getProperty(key); System.setProperty(key, value); } } lifecycleExecutor.execute(session, rm, session.getEventDispatcher()); }
From source file:org.opencredo.maven.plugins.enforcer.EnforcerTestUtils.java
License:Apache License
/** * Gets the maven session./*from w w w . j ava 2 s . com*/ * * @return the maven session */ public static MavenSession getMavenSession() { MockPlexusContainer container = new MockPlexusContainer(); container.addComponent(DependencyTreeBuilder.class, new DependencyTreeBuilder() { public DependencyTree buildDependencyTree(MavenProject project, ArtifactRepository repository, ArtifactFactory factory, ArtifactMetadataSource metadataSource, ArtifactCollector collector) throws DependencyTreeBuilderException { return null; } public DependencyNode buildDependencyTree(MavenProject project, ArtifactRepository repository, ArtifactFactory factory, ArtifactMetadataSource metadataSource, ArtifactFilter filter, ArtifactCollector collector) throws DependencyTreeBuilderException { return null; } }); return new MavenSession(container, null, null, null, null, null, null, new Properties(), new Date()); }
From source file:org.sonar.batch.maven.DefaultMavenPluginExecutor.java
License:Open Source License
public void concreteExecuteMaven2(Method executeMethod, MavenProject pom, String goal) { try {/* w w w. jav a2 s .co m*/ ReactorManager reactor = new ReactorManager(Arrays.asList(pom)); MavenSession clonedSession = new MavenSession(mavenSession.getContainer(), mavenSession.getSettings(), mavenSession.getLocalRepository(), mavenSession.getEventDispatcher(), reactor, Arrays.asList(goal), mavenSession.getExecutionRootDirectory(), mavenSession.getExecutionProperties(), mavenSession.getStartTime()); executeMethod.invoke(lifecycleExecutor, clonedSession, reactor, clonedSession.getEventDispatcher()); } catch (Exception e) { throw new SonarException("Unable to execute Maven 2 plugin", e); } }
From source file:org.sonar.maven.Maven2PluginExecutor.java
License:Open Source License
@Override public void concreteExecute(MavenProject pom, String goal) throws Exception { ReactorManager reactor = new ReactorManager(Arrays.asList(pom)); MavenSession clonedSession = new MavenSession(mavenSession.getContainer(), mavenSession.getSettings(), mavenSession.getLocalRepository(), mavenSession.getEventDispatcher(), reactor, Arrays.asList(goal), mavenSession.getExecutionRootDirectory(), mavenSession.getExecutionProperties(), mavenSession.getStartTime()); lifecycleExecutor.execute(clonedSession, reactor, clonedSession.getEventDispatcher()); }