/** * Method removeExecution. * * @param pluginExecution */ public void removeExecution( PluginExecution pluginExecution ) { getExecutions().remove( pluginExecution ); } //-- void removeExecution( PluginExecution )
List parentExecutions = parent.getExecutions(); for ( Iterator it = child.getExecutions().iterator(); it.hasNext(); )
/** * Method addExecution. * * @param pluginExecution */ public void addExecution( PluginExecution pluginExecution ) { getExecutions().add( pluginExecution ); } //-- void addExecution( PluginExecution )
List<PluginExecution> parentExecutions = parent.getExecutions(); for ( PluginExecution childExecution : child.getExecutions() )
private String getExecutionId( Plugin plugin, String goal ) { Set<String> existingIds = new HashSet<>(); for ( PluginExecution execution : plugin.getExecutions() ) { existingIds.add( execution.getId() ); } String base = "default-" + goal; String id = base; for ( int index = 1; existingIds.contains( id ); index++ ) { id = base + '-' + index; } return id; }
private static Xpp3Dom getMojoConfiguration( Plugin plugin ) { // // We need to look in the configuration element, and then look for configuration elements // within the executions. // Xpp3Dom configuration = ( Xpp3Dom ) plugin.getConfiguration(); if ( configuration == null ) { if ( !plugin.getExecutions().isEmpty() ) { configuration = ( Xpp3Dom ) plugin.getExecutions().get( 0 ).getConfiguration(); } } return configuration; } }
protected void mergePlugin_Executions( Plugin target, Plugin source, boolean sourceDominant, Map<Object, Object> context ) { List<PluginExecution> src = source.getExecutions(); if ( !src.isEmpty() ) { List<PluginExecution> tgt = target.getExecutions(); Map<Object, PluginExecution> merged = new LinkedHashMap<>( ( src.size() + tgt.size() ) * 2 ); for ( PluginExecution element : tgt ) { Object key = getPluginExecutionKey( element ); merged.put( key, element ); } for ( PluginExecution element : src ) { Object key = getPluginExecutionKey( element ); if ( sourceDominant || !merged.containsKey( key ) ) { merged.put( key, element ); } } target.setExecutions( new ArrayList<>( merged.values() ) ); } }
/** * @return a Map of executions field with <code>PluginExecution#getId()</code> as key * @see org.apache.maven.model.PluginExecution#getId() */ public java.util.Map<String, PluginExecution> getExecutionsAsMap() { if ( executionMap == null ) { executionMap = new java.util.LinkedHashMap<String, PluginExecution>(); if ( getExecutions() != null ) { for ( java.util.Iterator<PluginExecution> i = getExecutions().iterator(); i.hasNext(); ) { PluginExecution exec = (PluginExecution) i.next(); if ( executionMap.containsKey( exec.getId() ) ) { throw new IllegalStateException( "You cannot have two plugin executions with the same (or missing) <id/> elements.\nOffending execution\n\nId: \'" + exec.getId() + "\'\nPlugin:\'" + getKey() + "\'\n\n" ); } executionMap.put( exec.getId(), exec ); } } } return executionMap; }
Map<Object, Object> context ) List<PluginExecution> src = source.getExecutions(); if ( !src.isEmpty() ) List<PluginExecution> tgt = target.getExecutions(); Map<Object, PluginExecution> merged = new LinkedHashMap<>( ( src.size() + tgt.size() ) * 2 );
@Override protected void mergePlugin_Executions( Plugin target, Plugin source, boolean sourceDominant, Map<Object, Object> context ) { List<PluginExecution> src = source.getExecutions(); if ( !src.isEmpty() ) { List<PluginExecution> tgt = target.getExecutions(); Map<Object, PluginExecution> merged = new LinkedHashMap<>( ( src.size() + tgt.size() ) * 2 ); for ( PluginExecution element : src ) { Object key = getPluginExecutionKey( element ); merged.put( key, element.clone() ); } for ( PluginExecution element : tgt ) { Object key = getPluginExecutionKey( element ); PluginExecution existing = merged.get( key ); if ( existing != null ) { mergePluginExecution( element, existing, sourceDominant, context ); } merged.put( key, element ); } target.setExecutions( new ArrayList<>( merged.values() ) ); } } }
Map<Object, Object> context ) List<PluginExecution> src = source.getExecutions(); if ( !src.isEmpty() ) List<PluginExecution> tgt = target.getExecutions(); Map<Object, PluginExecution> merged = new LinkedHashMap<>( ( src.size() + tgt.size() ) * 2 );
private void mergeDeterministicPluginElements( List iPlugins, List dPlugins ) { if ( dPlugins != null ) { for ( int i = 0; i < dPlugins.size(); i++ ) { Plugin dPlugin = (Plugin) dPlugins.get( i ); Plugin iPlugin = (Plugin) iPlugins.get( i ); dPlugin.setGroupId( iPlugin.getGroupId() ); dPlugin.setArtifactId( iPlugin.getArtifactId() ); dPlugin.setVersion( iPlugin.getVersion() ); dPlugin.setDependencies( iPlugin.getDependencies() ); List dExecutions = dPlugin.getExecutions(); if ( dExecutions != null ) { List iExecutions = iPlugin.getExecutions(); for ( int j = 0; j < dExecutions.size(); j++ ) { PluginExecution dExec = (PluginExecution) dExecutions.get( j ); PluginExecution iExec = (PluginExecution) iExecutions.get( j ); dExec.setId( iExec.getId() ); } } } } }
if ( element.isInherited() || !element.getExecutions().isEmpty() )
for ( PluginExecution execution : plugin.getExecutions() )
private void expand( List<Plugin> plugins ) { for ( Plugin plugin : plugins ) { Xpp3Dom pluginConfiguration = (Xpp3Dom) plugin.getConfiguration(); if ( pluginConfiguration != null ) { for ( PluginExecution execution : plugin.getExecutions() ) { Xpp3Dom executionConfiguration = (Xpp3Dom) execution.getConfiguration(); executionConfiguration = Xpp3Dom.mergeXpp3Dom( executionConfiguration, new Xpp3Dom( pluginConfiguration ) ); execution.setConfiguration( executionConfiguration ); } } } }
for ( PluginExecution exec : plugin.getExecutions() )
for ( PluginExecution execution : plugin.getExecutions() )
plugin.getExecutions().add( execution );
public static Plugin clonePlugin( Plugin src ) { Plugin result = null; if ( src != null ) { result = new Plugin(); result.setArtifactId( src.getArtifactId() ); result.setConfiguration( cloneConfiguration( src.getConfiguration() ) ); result.setDependencies( cloneList( src.getDependencies(), DEPENDENCY_CLONER ) ); result.setExecutions( cloneList( src.getExecutions(), PLUGIN_EXECUTION_CLONER ) ); result.setExtensions( src.isExtensions() ); result.setGroupId( src.getGroupId() ); result.setInherited( src.getInherited() ); result.setVersion( src.getVersion() ); } return result; }
@Override public void configure( MavenProject project, MojoExecution mojoExecution, boolean allowPluginLevelConfig ) { String g = mojoExecution.getGroupId(); String a = mojoExecution.getArtifactId(); Plugin plugin = findPlugin( g, a, project.getBuildPlugins() ); if ( plugin == null && project.getPluginManagement() != null ) { plugin = findPlugin( g, a, project.getPluginManagement().getPlugins() ); } if ( plugin != null ) { PluginExecution pluginExecution = findPluginExecution( mojoExecution.getExecutionId(), plugin.getExecutions() ); Xpp3Dom pomConfiguration = null; if ( pluginExecution != null ) { pomConfiguration = (Xpp3Dom) pluginExecution.getConfiguration(); } else if ( allowPluginLevelConfig ) { pomConfiguration = (Xpp3Dom) plugin.getConfiguration(); } Xpp3Dom mojoConfiguration = ( pomConfiguration != null ) ? new Xpp3Dom( pomConfiguration ) : null; mojoConfiguration = Xpp3Dom.mergeXpp3Dom( mojoExecution.getConfiguration(), mojoConfiguration ); mojoExecution.setConfiguration( mojoConfiguration ); } }