Java Code Examples for org.apache.maven.model.Plugin#getKey()

The following examples show how to use org.apache.maven.model.Plugin#getKey() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DisplayPluginUpdatesMojo.java    From versions-maven-plugin with Apache License 2.0 5 votes vote down vote up
/**
 * Adds those project plugins which are not inherited from the parent definitions to the list of plugins.
 *
 * @param plugins The list of plugins.
 * @param projectPlugins The project's plugins.
 * @param parentDefinitions The parent plugin definitions.
 * @since 1.0-alpha-1
 */
private void addProjectPlugins( Map<String, Plugin> plugins, Collection<Plugin> projectPlugins,
                                Map<String, String> parentDefinitions )
{
    for ( Plugin plugin : projectPlugins )
    {
        String coord = plugin.getKey();
        String version = plugin.getVersion();
        String parentVersion = parentDefinitions.get( coord );
        if ( version == null
            && ( !plugins.containsKey( coord ) || plugins.get( coord ).getVersion() == null )
            && parentVersion != null )
        {
            Plugin parentPlugin = new Plugin();
            parentPlugin.setGroupId( plugin.getGroupId() );
            parentPlugin.setArtifactId( plugin.getArtifactId() );
            parentPlugin.setVersion( parentVersion );
            plugins.put( coord, parentPlugin );
        }
        else if ( parentVersion == null || !parentVersion.equals( version ) )
        {
            if ( !plugins.containsKey( coord ) || plugins.get( coord ).getVersion() == null )
            {
                plugins.put( coord, plugin );
            }
        }
        if ( !plugins.containsKey( coord ) )
        {
            plugins.put( coord, plugin );
        }
    }
}
 
Example 2
Source File: MavenProjectUtil.java    From ci.maven with Apache License 2.0 5 votes vote down vote up
/**
 * Get an execution of a plugin
 * @param plugin
 * @param goal
 * @return the execution object
 * @throws PluginScenarioException
 */
public static PluginExecution getPluginGoalExecution(Plugin plugin, String goal) throws PluginScenarioException {
    List<PluginExecution> executions = plugin.getExecutions();
    
    for(Iterator<PluginExecution> iterator = executions.iterator(); iterator.hasNext();) {
        PluginExecution execution = (PluginExecution) iterator.next();
        if(execution.getGoals().contains(goal)) {
            return execution;
        }
    }
    throw new PluginScenarioException("Could not find goal " + goal + " on plugin " + plugin.getKey());
}