public MojoDescriptor getMojoDescriptor( Plugin plugin, String goal, List<RemoteRepository> repositories, RepositorySystemSession session ) throws MojoNotFoundException, PluginResolutionException, PluginDescriptorParsingException, InvalidPluginDescriptorException { PluginDescriptor pluginDescriptor = getPluginDescriptor( plugin, repositories, session ); MojoDescriptor mojoDescriptor = pluginDescriptor.getMojo( goal ); if ( mojoDescriptor == null ) { throw new MojoNotFoundException( goal, pluginDescriptor ); } return mojoDescriptor; }
MojoDescriptor descriptor = pluginDescriptor.getMojo( HELP_GOAL );
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 List<MojoExecution> calculateForkedGoal( MojoExecution mojoExecution, MavenSession session, MavenProject project, Collection<MojoDescriptor> alreadyForkedExecutions ) throws MojoNotFoundException, PluginNotFoundException, PluginResolutionException, PluginDescriptorParsingException, NoPluginFoundForPrefixException, InvalidPluginDescriptorException, LifecyclePhaseNotFoundException, LifecycleNotFoundException, PluginVersionResolutionException { MojoDescriptor mojoDescriptor = mojoExecution.getMojoDescriptor(); PluginDescriptor pluginDescriptor = mojoDescriptor.getPluginDescriptor(); String forkedGoal = mojoDescriptor.getExecuteGoal(); MojoDescriptor forkedMojoDescriptor = pluginDescriptor.getMojo( forkedGoal ); if ( forkedMojoDescriptor == null ) { throw new MojoNotFoundException( forkedGoal, pluginDescriptor ); } if ( alreadyForkedExecutions.contains( forkedMojoDescriptor ) ) { return Collections.emptyList(); } MojoExecution forkedExecution = new MojoExecution( forkedMojoDescriptor, forkedGoal ); mojoExecutionConfigurator( forkedExecution ).configure( project, forkedExecution, true ); finalizeMojoConfiguration( forkedExecution ); calculateForkedExecutions( forkedExecution, session, project, alreadyForkedExecutions ); return Collections.singletonList( forkedExecution ); }
forkedMojoDescriptor = pluginDescriptor.getMojo( goal ); if ( forkedMojoDescriptor == null )
private static void updateHelpMojoDescriptor( PluginDescriptor pluginDescriptor, String helpMojoImplementation ) { MojoDescriptor mojoDescriptor = pluginDescriptor.getMojo( HELP_GOAL ); if ( mojoDescriptor != null ) { mojoDescriptor.setImplementation( helpMojoImplementation ); } } }
public PlexusConfiguration mojoConfigurationFor(Object mojoInstance, PlexusConfiguration pluginConfigurationFromMaven) throws ComponentConfigurationException { try (InputStream is = mojoInstance.getClass().getResourceAsStream("/META-INF/maven/plugin.xml")) { PluginDescriptor pd = pluginDescriptorBuilder.build(new InputStreamReader(is, "UTF-8")); // closes input stream too String goal = determineGoal(mojoInstance.getClass().getName(), pd); PlexusConfiguration defaultMojoConfiguration = pd.getMojo(goal).getMojoConfiguration(); PlexusConfiguration mojoConfiguration = extractAndMerge(goal, pluginConfigurationFromMaven, defaultMojoConfiguration); return mojoConfiguration; } catch (Exception e) { throw new ComponentConfigurationException(e); } }
public PlexusConfiguration mojoConfigurationFor(Object mojoInstance, PlexusConfiguration pluginConfigurationFromMaven) throws ComponentConfigurationException { try (InputStream is = mojoInstance.getClass().getResourceAsStream("/META-INF/maven/plugin.xml")) { PluginDescriptor pd = pluginDescriptorBuilder.build(new InputStreamReader(is, "UTF-8")); // closes input stream too String goal = determineGoal(mojoInstance.getClass().getName(), pd); PlexusConfiguration defaultMojoConfiguration = pd.getMojo(goal).getMojoConfiguration(); PlexusConfiguration mojoConfiguration = extractAndMerge(goal, pluginConfigurationFromMaven, defaultMojoConfiguration); return mojoConfiguration; } catch (Exception e) { throw new ComponentConfigurationException(e); } }
/** * Create descriptor. * @param plugin The plugin * @param goal Maven plugin goal to execute * @return The descriptor */ private MojoDescriptor descriptor(final Plugin plugin, final String goal) { try { return this.helper.getPluginDescriptor( plugin, this.session.getCurrentProject().getRemotePluginRepositories(), this.session ).getMojo(goal); } catch (final PluginResolutionException ex) { throw new IllegalStateException("Can't resolve plugin", ex); } catch (final PluginDescriptorParsingException ex) { throw new IllegalStateException("Can't parse descriptor", ex); } catch (final InvalidPluginDescriptorException ex) { throw new IllegalStateException("Invalid plugin descriptor", ex); } }
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); } }
MojoDescriptor mojoDescriptor = pluginDescriptor.getMojo(goal); if (mojoDescriptor == null) { throw new MojoExecutionException("Could not find goal '" + goal + "' in plugin "
session.getRepositorySession()); MojoDescriptor mojoDescriptor = pluginDescriptor.getMojo(goal);
MojoDescriptor mojoDescriptor = pluginDescriptor.getMojo(goal); if (mojoDescriptor == null) { throw new MojoExecutionException("Could not find goal '" + goal + "' in plugin "
return pluginDescriptor.getMojo(goal).getParameters();
@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); }
throw new MojoExecutionException(MessageFormat.format(Messages.AbstractSarlMojo_1, plugin.getId())); final MojoDescriptor mojoDescriptor = pluginDescriptor.getMojo(goal); if (mojoDescriptor == null) { throw new MojoExecutionException(MessageFormat.format(Messages.AbstractSarlMojo_2, goal));
MojoDescriptor mojoDescriptor = pluginDescriptor.getMojo("enhance");
MojoDescriptor mojoDescriptor = pluginDescriptor.getMojo("enhance");
? MAVEN_COMPILER_PLUGIN_TEST_GOAL : MAVEN_COMPILER_PLUGIN_STANDARD_GOAL; final MojoDescriptor mojoDescriptor = pluginDescriptor.getMojo(goal); if (mojoDescriptor != null) { final Xpp3Dom mojoConfiguration;