List of usage examples for org.apache.maven.plugin Mojo execute
void execute() throws MojoExecutionException, MojoFailureException;
Mojo
implements.Mojo
inside the Maven
system, and allows the Mojo
to communicate errors. From source file:com.github.born2snipe.maven.plugin.idea.BaseMojoTestCase.java
License:Apache License
protected void run(Mojo mojo) { try {/*from w w w . jav a 2 s. co m*/ mojo.execute(); } catch (RuntimeException e) { throw e; } catch (Exception e) { throw new RuntimeException(e); } }
From source file:io.takari.maven.testing.Maven30xRuntime.java
License:Open Source License
@Override public Mojo executeMojo(MavenSession session, MavenProject project, MojoExecution execution) throws Exception { Mojo mojo = lookupConfiguredMojo(session, execution); mojo.execute(); return mojo;/*www . j a va 2 s . co m*/ }
From source file:org.codehaus.mojo.sonar.Bootstraper.java
License:Open Source License
private void executeMojo(MavenProject project, MavenSession session) throws MojoExecutionException { ClassLoader originalClassLoader = Thread.currentThread().getContextClassLoader(); try {//from w ww. ja v a2 s .c o m RepositoryRequest repositoryRequest = new DefaultRepositoryRequest(); repositoryRequest.setLocalRepository(session.getLocalRepository()); repositoryRequest.setRemoteRepositories(project.getPluginArtifactRepositories()); Plugin plugin = createSonarPlugin(); List<RemoteRepository> remoteRepositories = session.getCurrentProject().getRemotePluginRepositories(); PluginDescriptor pluginDescriptor = pluginManager.getPluginDescriptor(plugin, remoteRepositories, session.getRepositorySession()); String goal = "sonar"; MojoDescriptor mojoDescriptor = pluginDescriptor.getMojo(goal); if (mojoDescriptor == null) { throw new MojoExecutionException("Unknown mojo goal: " + goal); } MojoExecution mojoExecution = new MojoExecution(plugin, goal, "sonar" + goal); mojoExecution.setConfiguration(convert(mojoDescriptor)); mojoExecution.setMojoDescriptor(mojoDescriptor); // olamy : we exclude nothing and import nothing regarding realm import and artifacts DependencyFilter artifactFilter = new DependencyFilter() { public boolean accept(DependencyNode arg0, List<DependencyNode> arg1) { return true; } }; pluginManager.setupPluginRealm(pluginDescriptor, session, Thread.currentThread().getContextClassLoader(), Collections.<String>emptyList(), artifactFilter); Mojo mojo = pluginManager.getConfiguredMojo(Mojo.class, session, mojoExecution); Thread.currentThread().setContextClassLoader(pluginDescriptor.getClassRealm()); mojo.execute(); } catch (Exception e) { throw new MojoExecutionException("Can not execute Sonar", e); } finally { Thread.currentThread().setContextClassLoader(originalClassLoader); } }