public void callPluginGoal(String fullGoal) throws MojoFailureException, MojoExecutionException { String[] parts = splitGoalSpec(fullGoal); Plugin plugin = project.getPlugin(parts[0]); String goal = parts[1]; if (plugin == null) { throw new MojoFailureException("No goal " + fullGoal + " found in pom.xml"); } try { String executionId = null; if (goal != null && goal.length() > 0 && goal.indexOf('#') > -1) { int pos = goal.indexOf('#'); executionId = goal.substring(pos + 1); goal = goal.substring(0, pos); } PluginDescriptor pluginDescriptor = getPluginDescriptor(project, plugin); MojoDescriptor mojoDescriptor = pluginDescriptor.getMojo(goal); if (mojoDescriptor == null) { throw new MojoExecutionException("Could not find goal '" + goal + "' in plugin " + plugin.getGroupId() + ":" + plugin.getArtifactId() + ":" + plugin.getVersion()); } MojoExecution exec = getMojoExecution(executionId, mojoDescriptor); pluginManager.executeMojo(session, exec); } catch (Exception e) { throw new MojoExecutionException("Unable to execute mojo", e); } }
private PluginPrefixResult resolveFromProject( PluginPrefixRequest request, List<Plugin> plugins ) { for ( Plugin plugin : plugins ) { try { PluginDescriptor pluginDescriptor = pluginManager.loadPlugin( plugin, request.getRepositories(), request.getRepositorySession() ); if ( request.getPrefix().equals( pluginDescriptor.getGoalPrefix() ) ) { return new DefaultPluginPrefixResult( plugin ); } } catch ( Exception e ) { if ( logger.isDebugEnabled() ) { logger.warn( "Failed to retrieve plugin descriptor for " + plugin.getId() + ": " + e.getMessage(), e ); } else { logger.warn( "Failed to retrieve plugin descriptor for " + plugin.getId() + ": " + e.getMessage() ); } } } return null; }
return pluginManager.getMojoDescriptor( plugin, goal, project.getRemotePluginRepositories(), session.getRepositorySession() );
env.getPluginManager().loadPlugin( plugin, env.getMavenProject().getRemotePluginRepositories(), env.getPluginManager().executeMojo(session, exec);
ClassRealm pluginRealm = buildPluginManager.getPluginRealm(session, mojoExecution.getMojoDescriptor().getPluginDescriptor()); return new ResourceResolver(pluginRealm, projectLocation,
@SuppressWarnings("unchecked") protected void startProject(MavenProject project, String executionId, XmlPlexusConfiguration process) throws InvalidPluginDescriptorException, PluginResolutionException, PluginDescriptorParsingException, PluginNotFoundException, PluginConfigurationException, MojoFailureException, MojoExecutionException, PluginManagerException { Plugin plugin = this.project.getPlugin("org.wildfly.swarm:wildfly-swarm-plugin"); Xpp3Dom config = getConfiguration(project, executionId); Xpp3Dom processConfig = getProcessConfiguration(process); Xpp3Dom globalConfig = getGlobalConfig(); Xpp3Dom mergedConfig = Xpp3DomUtils.mergeXpp3Dom(processConfig, config); mergedConfig = Xpp3DomUtils.mergeXpp3Dom(mergedConfig, globalConfig); PluginDescriptor pluginDescriptor = this.pluginManager.loadPlugin(plugin, project.getRemotePluginRepositories(), this.repositorySystemSession); MojoDescriptor mojoDescriptor = pluginDescriptor.getMojo("start"); MojoExecution mojoExecution = new MojoExecution(mojoDescriptor, mergedConfig); mavenSession.setCurrentProject(project); this.pluginManager.executeMojo(mavenSession, mojoExecution); List<SwarmProcess> launched = (List<SwarmProcess>) mavenSession.getPluginContext(pluginDescriptor, project).get("swarm-process"); List<SwarmProcess> procs = (List<SwarmProcess>) getPluginContext().get("swarm-process"); if (procs == null) { procs = new ArrayList<>(); getPluginContext().put("swarm-process", procs); } procs.addAll(launched); mavenSession.setCurrentProject(this.project); }
session.setCurrentProject(project); try { pluginRealm = buildPluginManager.getPluginRealm(session, pluginDescriptor); } finally { session.setCurrentProject(oldCurrentProject);
pluginDescriptor = plugin_manager.loadPlugin(plugin, project.getRemotePluginRepositories(), session.getRepositorySession()); plugin_manager.executeMojo(session, exec); } catch (MojoFailureException | MojoExecutionException | PluginConfigurationException | PluginManagerException e) {
pluginManager.executeMojo( session, mojoExecution );
private PluginDescriptor getPluginDescriptor(MavenProject project, Plugin plugin) throws PluginResolutionException, PluginDescriptorParsingException, InvalidPluginDescriptorException, PluginNotFoundException { RepositorySystemSession repositorySession = session.getRepositorySession(); return pluginManager.loadPlugin(plugin, project.getRemotePluginRepositories(), repositorySession); }
pluginManager.getMojoDescriptor( plugin, goal, project.getRemotePluginRepositories(), session.getRepositorySession() );
pluginDescriptor = plugin_manager.loadPlugin(plugin, project.getRemotePluginRepositories(), session.getRepositorySession()); plugin_manager.executeMojo(session, exec); } catch (MojoFailureException | MojoExecutionException | PluginConfigurationException | PluginManagerException e) {
/** Execute the given mojo. * * @param mojo the mojo to execute. * @throws MojoExecutionException if the mojo cannot be run properly. * @throws MojoFailureException if the build failed. */ public void executeMojo(MojoExecution mojo) throws MojoExecutionException, MojoFailureException { try { this.buildPluginManager.executeMojo(this.session, mojo); } catch (PluginConfigurationException | PluginManagerException e) { throw new MojoFailureException(e.getLocalizedMessage(), e); } }
pluginManager.getMojoDescriptor( forkedExecution.getPlugin(), forkedExecution.getGoal(), project.getRemotePluginRepositories(), session.getRepositorySession() );
public void callPluginGoal(String fullGoal) throws MojoFailureException, MojoExecutionException { String[] parts = splitGoalSpec(fullGoal); Plugin plugin = project.getPlugin(parts[0]); String goal = parts[1]; if (plugin == null) { throw new MojoFailureException("No goal " + fullGoal + " found in pom.xml"); } try { String executionId = null; if (goal != null && goal.length() > 0 && goal.indexOf('#') > -1) { int pos = goal.indexOf('#'); executionId = goal.substring(pos + 1); goal = goal.substring(0, pos); } PluginDescriptor pluginDescriptor = getPluginDescriptor(project, plugin); MojoDescriptor mojoDescriptor = pluginDescriptor.getMojo(goal); if (mojoDescriptor == null) { throw new MojoExecutionException("Could not find goal '" + goal + "' in plugin " + plugin.getGroupId() + ":" + plugin.getArtifactId() + ":" + plugin.getVersion()); } MojoExecution exec = getMojoExecution(executionId, mojoDescriptor); pluginManager.executeMojo(session, exec); } catch (Exception e) { throw new MojoExecutionException("Unable to execute mojo", e); } }
@Override public void setupMojoExecution( MavenSession session, MavenProject project, MojoExecution mojoExecution ) throws PluginNotFoundException, PluginResolutionException, PluginDescriptorParsingException, MojoNotFoundException, InvalidPluginDescriptorException, NoPluginFoundForPrefixException, LifecyclePhaseNotFoundException, LifecycleNotFoundException, PluginVersionResolutionException { MojoDescriptor mojoDescriptor = mojoExecution.getMojoDescriptor(); if ( mojoDescriptor == null ) { mojoDescriptor = pluginManager.getMojoDescriptor( mojoExecution.getPlugin(), mojoExecution.getGoal(), project.getRemotePluginRepositories(), session.getRepositorySession() ); mojoExecution.setMojoDescriptor( mojoDescriptor ); } mojoExecutionConfigurator( mojoExecution ).configure( project, mojoExecution, MojoExecution.Source.CLI.equals( mojoExecution.getSource() ) ); finalizeMojoConfiguration( mojoExecution ); calculateForkedExecutions( mojoExecution, session, project, new HashSet<MojoDescriptor>() ); }
env.getPluginManager().executeMojo(session, exec);
Plugin plugin, String goal, Xpp3Dom configuration) { try { MojoDescriptor descriptor = mojo.pluginManager.getMojoDescriptor(plugin, goal, mojo.remoteRepos, mojo.repoSession); final List<Parameter> parameters = descriptor.getParameters();
env.getPluginManager().executeMojo(session, exec);