diff --git a/maven-core/src/main/java/org/apache/maven/lifecycle/DefaultLifecycleExecutor.java b/maven-core/src/main/java/org/apache/maven/lifecycle/DefaultLifecycleExecutor.java index 9bb6ee5d5e..a3a9940dee 100644 --- a/maven-core/src/main/java/org/apache/maven/lifecycle/DefaultLifecycleExecutor.java +++ b/maven-core/src/main/java/org/apache/maven/lifecycle/DefaultLifecycleExecutor.java @@ -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> lifecycleMappings = new LinkedHashMap>(); + Map>> mappings = + new LinkedHashMap>>(); for ( String phase : lifecycle.getPhases() ) { - List mojoExecutions = new ArrayList(); + Map> phaseBindings = new TreeMap>(); - 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 mojoExecutions = lifecycleMappings.get( execution.getPhase() ); - if ( mojoExecutions != null ) + Map> 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 mojoExecutions = lifecycleMappings.get( mojoDescriptor.getPhase() ); - if ( mojoExecutions != null ) + Map> phaseBindings = mappings.get( mojoDescriptor.getPhase() ); + if ( phaseBindings != null ) { MojoExecution mojoExecution = new MojoExecution( mojoDescriptor, execution.getId() ); - mojoExecutions.add( mojoExecution ); + addMojoExecution( phaseBindings, mojoExecution, execution.getPriority() ); } } } } } + Map> lifecycleMappings = new LinkedHashMap>(); + + for ( Map.Entry>> entry : mappings.entrySet() ) + { + List mojoExecutions = new ArrayList(); + + for ( List executions : entry.getValue().values() ) + { + mojoExecutions.addAll( executions ); + } + + lifecycleMappings.put( entry.getKey(), mojoExecutions ); + } + return lifecycleMappings; } + private void addMojoExecution( Map> phaseBindings, MojoExecution mojoExecution, + int priority ) + { + List mojoExecutions = phaseBindings.get( priority ); + + if ( mojoExecutions == null ) + { + mojoExecutions = new ArrayList(); + 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(); diff --git a/maven-model/src/main/mdo/maven.mdo b/maven-model/src/main/mdo/maven.mdo index f719a233ce..e7b790bd15 100644 --- a/maven-model/src/main/mdo/maven.mdo +++ b/maven-model/src/main/mdo/maven.mdo @@ -2902,6 +2902,19 @@ 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. + + priority + 4.0.0 + int + + Warning: 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. + ]]> + + goals 4.0.0