diff --git a/maven-core/src/main/java/org/apache/maven/execution/DefaultMavenExecutionRequest.java b/maven-core/src/main/java/org/apache/maven/execution/DefaultMavenExecutionRequest.java index 58f6f2a27e..e8a568f549 100644 --- a/maven-core/src/main/java/org/apache/maven/execution/DefaultMavenExecutionRequest.java +++ b/maven-core/src/main/java/org/apache/maven/execution/DefaultMavenExecutionRequest.java @@ -127,8 +127,8 @@ public class DefaultMavenExecutionRequest private ExecutionListener executionListener; private String threadCount; + private boolean perCoreThreadCount; - private boolean weaveMode; /** * Suppress SNAPSHOT updates. @@ -1028,28 +1028,29 @@ public MavenExecutionRequest setExecutionListener( ExecutionListener executionLi return this; } - public String getThreadCount() { + public String getThreadCount() + { return threadCount; } - public void setThreadCount(String threadCount) { + public void setThreadCount( String threadCount ) + { this.threadCount = threadCount; } - public boolean isThreadConfigurationPresent() { + public boolean isThreadConfigurationPresent() + { return getThreadCount() != null; } - public boolean isPerCoreThreadCount() { + public boolean isPerCoreThreadCount() + { return perCoreThreadCount; } - public void setPerCoreThreadCount(boolean perCoreThreadCount) { + public void setPerCoreThreadCount( boolean perCoreThreadCount ) + { this.perCoreThreadCount = perCoreThreadCount; } - public boolean isWeaveMode() { - return weaveMode; - } - } diff --git a/maven-core/src/main/java/org/apache/maven/execution/MavenExecutionRequest.java b/maven-core/src/main/java/org/apache/maven/execution/MavenExecutionRequest.java index 925e0599a4..81f0ce79a0 100644 --- a/maven-core/src/main/java/org/apache/maven/execution/MavenExecutionRequest.java +++ b/maven-core/src/main/java/org/apache/maven/execution/MavenExecutionRequest.java @@ -158,9 +158,6 @@ public interface MavenExecutionRequest void setPerCoreThreadCount(boolean perCoreThreadCount); boolean isPerCoreThreadCount(); - boolean isWeaveMode(); - - // Recursive (really to just process the top-level POM) MavenExecutionRequest setRecursive( boolean recursive ); boolean isRecursive(); diff --git a/maven-core/src/main/java/org/apache/maven/execution/MavenSession.java b/maven-core/src/main/java/org/apache/maven/execution/MavenSession.java index c8774846d7..060f5ac5d0 100644 --- a/maven-core/src/main/java/org/apache/maven/execution/MavenSession.java +++ b/maven-core/src/main/java/org/apache/maven/execution/MavenSession.java @@ -376,11 +376,13 @@ public Date getStartTime() return request.getStartTime(); } - public boolean isParallel() { + public boolean isParallel() + { return parallel; } - public void setParallel(boolean parallel) { + public void setParallel( boolean parallel ) + { this.parallel = parallel; } } 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 f4740a2596..5b0a6719f3 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 @@ -23,6 +23,7 @@ import org.apache.maven.lifecycle.internal.BuildListCalculator; import org.apache.maven.lifecycle.internal.ConcurrencyDependencyGraph; import org.apache.maven.lifecycle.internal.LifecycleDebugLogger; +import org.apache.maven.lifecycle.internal.LifecycleExecutionPlanCalculator; import org.apache.maven.lifecycle.internal.LifecycleModuleBuilder; import org.apache.maven.lifecycle.internal.LifecycleTaskSegmentCalculator; import org.apache.maven.lifecycle.internal.LifecycleThreadedBuilder; @@ -40,6 +41,7 @@ import org.apache.maven.plugin.MojoExecution; import org.apache.maven.plugin.MojoNotFoundException; import org.apache.maven.plugin.PluginDescriptorParsingException; +import org.apache.maven.plugin.PluginManagerException; import org.apache.maven.plugin.PluginNotFoundException; import org.apache.maven.plugin.PluginResolutionException; import org.apache.maven.plugin.descriptor.MojoDescriptor; @@ -93,6 +95,9 @@ public class DefaultLifecycleExecutor @Requirement private LifecycleTaskSegmentCalculator lifecycleTaskSegmentCalculator; + @Requirement + private LifecycleExecutionPlanCalculator lifecycleExecutionPlanCalculator; + @Requirement private ThreadConfigurationService threadConfigService; @@ -148,7 +153,7 @@ public void execute( MavenSession session ) { ExecutorService executor = threadConfigService.getExecutorService( executionRequest.getThreadCount(), executionRequest.isPerCoreThreadCount(), - session.getProjects().size()); + session.getProjects().size() ); try { @@ -169,7 +174,8 @@ public void execute( MavenSession session ) CompletionService service = new ExecutorCompletionService( executor ); - lifecycleThreadedBuilder.build( session, callableContext, projectBuilds, taskSegments, analyzer, service ); + lifecycleThreadedBuilder.build( session, callableContext, projectBuilds, taskSegments, analyzer, + service ); } } finally @@ -208,7 +214,8 @@ private void singleThreadedBuild( MavenSession session, ReactorContext callableC { try { - lifecycleModuleBuilder.buildProject( session, callableContext, projectBuild.getProject(), taskSegment ); + lifecycleModuleBuilder.buildProject( session, callableContext, projectBuild.getProject(), + taskSegment ); if ( reactorBuildStatus.isHalted() ) { break; @@ -279,5 +286,27 @@ MojoDescriptor getMojoDescriptor( String task, MavenSession session, MavenProjec return mojoDescriptorCreator.getMojoDescriptor( task, session, project ); } + // Used by m2eclipse + + @SuppressWarnings({"UnusedDeclaration"}) + public MavenExecutionPlan calculateExecutionPlan( MavenSession session, String... tasks ) + throws PluginNotFoundException, PluginResolutionException, PluginDescriptorParsingException, + MojoNotFoundException, NoPluginFoundForPrefixException, InvalidPluginDescriptorException, + PluginManagerException, LifecyclePhaseNotFoundException, LifecycleNotFoundException, + PluginVersionResolutionException + { + + List taskSegments = buildListCalculator.calculateTaskSegments( session ); + + TaskSegment mergedSegment = new TaskSegment( false ); + + for ( TaskSegment taskSegment : taskSegments ) + { + mergedSegment.getTasks().addAll( taskSegment.getTasks() ); + } + + return lifecycleExecutionPlanCalculator.calculateExecutionPlan( session, session.getCurrentProject(), + mergedSegment.getTasks() ); + } } diff --git a/maven-embedder/src/main/java/org/apache/maven/cli/MavenCli.java b/maven-embedder/src/main/java/org/apache/maven/cli/MavenCli.java index d8825869c0..d65ddfb299 100644 --- a/maven-embedder/src/main/java/org/apache/maven/cli/MavenCli.java +++ b/maven-embedder/src/main/java/org/apache/maven/cli/MavenCli.java @@ -866,21 +866,21 @@ else if ( commandLine.hasOption( CLIManager.ALSO_MAKE ) && commandLine.hasOption request.setLocalRepositoryPath( localRepoProperty ); } + final String threadConfiguration = commandLine.hasOption( CLIManager.THREADS ) + ? commandLine.getOptionValue( CLIManager.THREADS ) + : request.getSystemProperties().getProperty( + MavenCli.THREADS_DEPRECATED ); // TODO: Remove this setting. Note that the int-tests use it - final String threadConfiguration = commandLine.hasOption( CLIManager.THREADS ) ? - commandLine.getOptionValue( CLIManager.THREADS) : - request.getSystemProperties().getProperty(MavenCli.THREADS_DEPRECATED); // TODO: Remove this setting. Note that the int-tests use it - - if (threadConfiguration != null){ - request.setPerCoreThreadCount( threadConfiguration.contains("C")); - if (threadConfiguration.contains("W")) + if ( threadConfiguration != null ) + { + request.setPerCoreThreadCount( threadConfiguration.contains( "C" ) ); + if ( threadConfiguration.contains( "W" ) ) { - LifecycleWeaveBuilder.setWeaveMode(request.getUserProperties()); + LifecycleWeaveBuilder.setWeaveMode( request.getUserProperties() ); } - request.setThreadCount(threadConfiguration.replace("C", "").replace("W", "").replace("auto", "")); + request.setThreadCount( threadConfiguration.replace( "C", "" ).replace( "W", "" ).replace( "auto", "" ) ); } - return request; }