mirror of https://github.com/apache/maven.git
[MNG-4345] [regression] Plugin executions contributed by default lifecycle mapping execute after other plugin executions bound to the same phase
git-svn-id: https://svn.apache.org/repos/asf/maven/maven-3/trunk@812467 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
b614de4253
commit
c249a98408
|
@ -29,6 +29,7 @@ import java.util.List;
|
|||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.StringTokenizer;
|
||||
import java.util.TreeMap;
|
||||
import java.util.TreeSet;
|
||||
|
||||
import org.apache.maven.ProjectDependenciesResolver;
|
||||
|
@ -944,13 +945,14 @@ public class DefaultLifecycleExecutor
|
|||
* is interested in, i.e. all phases up to and including the specified phase.
|
||||
*/
|
||||
|
||||
Map<String, List<MojoExecution>> lifecycleMappings = new LinkedHashMap<String, List<MojoExecution>>();
|
||||
Map<String, Map<Integer, List<MojoExecution>>> mappings =
|
||||
new LinkedHashMap<String, Map<Integer, List<MojoExecution>>>();
|
||||
|
||||
for ( String phase : lifecycle.getPhases() )
|
||||
{
|
||||
List<MojoExecution> mojoExecutions = new ArrayList<MojoExecution>();
|
||||
Map<Integer, List<MojoExecution>> phaseBindings = new TreeMap<Integer, List<MojoExecution>>();
|
||||
|
||||
lifecycleMappings.put( phase, mojoExecutions );
|
||||
mappings.put( phase, phaseBindings );
|
||||
|
||||
if ( phase.equals( lifecyclePhase ) )
|
||||
{
|
||||
|
@ -973,13 +975,13 @@ public class DefaultLifecycleExecutor
|
|||
// to examine the phase it is associated to.
|
||||
if ( execution.getPhase() != null )
|
||||
{
|
||||
List<MojoExecution> mojoExecutions = lifecycleMappings.get( execution.getPhase() );
|
||||
if ( mojoExecutions != null )
|
||||
Map<Integer, List<MojoExecution>> phaseBindings = mappings.get( execution.getPhase() );
|
||||
if ( phaseBindings != null )
|
||||
{
|
||||
for ( String goal : execution.getGoals() )
|
||||
{
|
||||
MojoExecution mojoExecution = new MojoExecution( plugin, goal, execution.getId() );
|
||||
mojoExecutions.add( mojoExecution );
|
||||
addMojoExecution( phaseBindings, mojoExecution, execution.getPriority() );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -991,20 +993,48 @@ public class DefaultLifecycleExecutor
|
|||
MojoDescriptor mojoDescriptor =
|
||||
pluginManager.getMojoDescriptor( plugin, goal, getRepositoryRequest( session, project ) );
|
||||
|
||||
List<MojoExecution> mojoExecutions = lifecycleMappings.get( mojoDescriptor.getPhase() );
|
||||
if ( mojoExecutions != null )
|
||||
Map<Integer, List<MojoExecution>> phaseBindings = mappings.get( mojoDescriptor.getPhase() );
|
||||
if ( phaseBindings != null )
|
||||
{
|
||||
MojoExecution mojoExecution = new MojoExecution( mojoDescriptor, execution.getId() );
|
||||
mojoExecutions.add( mojoExecution );
|
||||
addMojoExecution( phaseBindings, mojoExecution, execution.getPriority() );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Map<String, List<MojoExecution>> lifecycleMappings = new LinkedHashMap<String, List<MojoExecution>>();
|
||||
|
||||
for ( Map.Entry<String, Map<Integer, List<MojoExecution>>> entry : mappings.entrySet() )
|
||||
{
|
||||
List<MojoExecution> mojoExecutions = new ArrayList<MojoExecution>();
|
||||
|
||||
for ( List<MojoExecution> executions : entry.getValue().values() )
|
||||
{
|
||||
mojoExecutions.addAll( executions );
|
||||
}
|
||||
|
||||
lifecycleMappings.put( entry.getKey(), mojoExecutions );
|
||||
}
|
||||
|
||||
return lifecycleMappings;
|
||||
}
|
||||
|
||||
private void addMojoExecution( Map<Integer, List<MojoExecution>> phaseBindings, MojoExecution mojoExecution,
|
||||
int priority )
|
||||
{
|
||||
List<MojoExecution> mojoExecutions = phaseBindings.get( priority );
|
||||
|
||||
if ( mojoExecutions == null )
|
||||
{
|
||||
mojoExecutions = new ArrayList<MojoExecution>();
|
||||
phaseBindings.put( priority, mojoExecutions );
|
||||
}
|
||||
|
||||
mojoExecutions.add( mojoExecution );
|
||||
}
|
||||
|
||||
public void calculateForkedExecutions( MojoExecution mojoExecution, MavenSession session )
|
||||
throws MojoNotFoundException, PluginNotFoundException, PluginResolutionException,
|
||||
PluginDescriptorParsingException, NoPluginFoundForPrefixException, InvalidPluginDescriptorException,
|
||||
|
@ -1591,6 +1621,7 @@ public class DefaultLifecycleExecutor
|
|||
PluginExecution execution = new PluginExecution();
|
||||
execution.setId( "default-" + p[p.length - 1] );
|
||||
execution.setPhase( phase );
|
||||
execution.setPriority( -1 );
|
||||
execution.getGoals().add( p[p.length - 1] );
|
||||
|
||||
Plugin plugin = new Plugin();
|
||||
|
|
|
@ -2902,6 +2902,19 @@
|
|||
<description>The build lifecycle phase to bind the goals in this execution to. If omitted,
|
||||
the goals will be bound to the default phase specified in their metadata. </description>
|
||||
</field>
|
||||
<field xml.transient="true">
|
||||
<name>priority</name>
|
||||
<version>4.0.0</version>
|
||||
<type>int</type>
|
||||
<description>
|
||||
<![CDATA[
|
||||
The priority of this execution compared to other executions which are bound to the same phase.
|
||||
<strong>Warning:</strong> This is an internal utility property that is only public for technical reasons,
|
||||
it is not part of the public API. In particular, this property can be changed or deleted without prior
|
||||
notice.
|
||||
]]>
|
||||
</description>
|
||||
</field>
|
||||
<field>
|
||||
<name>goals</name>
|
||||
<version>4.0.0</version>
|
||||
|
|
Loading…
Reference in New Issue