List of usage examples for org.apache.maven.eventspy.internal EventSpyDispatcher getEventSpies
public List<EventSpy> getEventSpies()
From source file:org.jvnet.hudson.maven3.launcher.Maven31Launcher.java
License:Apache License
public static int main(String[] args) throws Exception { ClassLoader orig = Thread.currentThread().getContextClassLoader(); try {//from ww w. j a v a2s. c om ClassRealm containerRealm = (ClassRealm) Thread.currentThread().getContextClassLoader(); ContainerConfiguration cc = new DefaultContainerConfiguration().setName("maven") .setRealm(containerRealm).setClassPathScanning(PlexusConstants.SCANNING_INDEX) .setAutoWiring(true); DefaultPlexusContainer container = new DefaultPlexusContainer(cc); Slf4jLoggerManager mavenLoggerManager = new Slf4jLoggerManager(); container.setLoggerManager(mavenLoggerManager); Maven maven = (Maven) container.lookup("org.apache.maven.Maven", "default"); EventSpyDispatcher eventSpyDispatcher = container.lookup(EventSpyDispatcher.class); if (eventSpiesList != null && !eventSpiesList.isEmpty()) { List<EventSpy> eventSpies = eventSpyDispatcher.getEventSpies(); if (eventSpies == null) { eventSpies = new ArrayList<EventSpy>(1); } eventSpies.addAll(eventSpiesList); // get event spies added with plexus components // see Maven31Maven addPlexusComponents // PlexusModuleContributor extension List<EventSpy> spies = container.lookupList(EventSpy.class); if (spies != null && !spies.isEmpty()) { eventSpies.addAll(spies); } eventSpyDispatcher.setEventSpies(eventSpies); } MavenExecutionRequest request = getMavenExecutionRequest(args, container); MavenExecutionResult result = maven.execute(request); hudsonMavenExecutionResult = new HudsonMavenExecutionResult(result); // we don't care about cli mavenExecutionResult will be study in the the plugin return 0;// cli.doMain( args, null ); } catch (ComponentLookupException e) { throw new Exception(e.getMessage(), e); } finally { Thread.currentThread().setContextClassLoader(orig); } }
From source file:org.jvnet.hudson.maven3.launcher.Maven35Launcher.java
License:Apache License
public static int main(String[] args, ClassWorld classWorld) throws Exception { ClassLoader orig = Thread.currentThread().getContextClassLoader(); try {//from ww w. j a v a2 s.c o m ClassRealm containerRealm = (ClassRealm) Thread.currentThread().getContextClassLoader(); ContainerConfiguration cc = new DefaultContainerConfiguration().setName("maven") .setRealm(containerRealm).setClassPathScanning(PlexusConstants.SCANNING_INDEX) .setAutoWiring(true); DefaultPlexusContainer container = new DefaultPlexusContainer(cc); Slf4jLoggerManager mavenLoggerManager = new Slf4jLoggerManager(); container.setLoggerManager(mavenLoggerManager); Maven maven = (Maven) container.lookup("org.apache.maven.Maven", "default"); EventSpyDispatcher eventSpyDispatcher = container.lookup(EventSpyDispatcher.class); if (eventSpiesList != null && !eventSpiesList.isEmpty()) { List<EventSpy> eventSpies = eventSpyDispatcher.getEventSpies(); if (eventSpies == null) { eventSpies = new ArrayList<EventSpy>(1); } eventSpies.addAll(eventSpiesList); // get event spies added with plexus components // see Maven31Maven addPlexusComponents // PlexusModuleContributor extension List<EventSpy> spies = container.lookupList(EventSpy.class); if (spies != null && !spies.isEmpty()) { eventSpies.addAll(spies); } eventSpyDispatcher.setEventSpies(eventSpies); } MavenExecutionRequest request = getMavenExecutionRequest(args, container); MavenExecutionResult result = maven.execute(request); hudsonMavenExecutionResult = new HudsonMavenExecutionResult(result); // we don't care about cli mavenExecutionResult will be study in the the plugin return 0;// cli.doMain( args, null ); } catch (ComponentLookupException e) { throw new Exception(e.getMessage(), e); } finally { Thread.currentThread().setContextClassLoader(orig); } }