mirror of
https://github.com/apache/maven.git
synced 2025-02-08 11:05:37 +00:00
[MNG-7381] Shorten parallel builder thread name to artifactId, conditionally with groupId
This closes #662
This commit is contained in:
parent
c0a49c7396
commit
ab4fec0a33
@ -21,6 +21,7 @@
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.Callable;
|
||||
import java.util.concurrent.CompletionService;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
@ -28,6 +29,8 @@
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Named;
|
||||
@ -129,6 +132,14 @@ private void multiThreadedProjectTaskSegmentBuild( ConcurrencyDependencyGraph an
|
||||
Map<MavenProject, ProjectSegment> projectBuildList,
|
||||
ThreadOutputMuxer muxer )
|
||||
{
|
||||
// gather artifactIds which are not unique so that the respective thread names can be extended with the groupId
|
||||
Set<String> duplicateArtifactIds = projectBuildList.keySet().stream()
|
||||
.map( MavenProject::getArtifactId )
|
||||
.collect( Collectors.groupingBy( Function.identity(), Collectors.counting() ) )
|
||||
.entrySet().stream()
|
||||
.filter( p -> p.getValue() > 1 )
|
||||
.map( Map.Entry::getKey )
|
||||
.collect( Collectors.toSet() );
|
||||
|
||||
// schedule independent projects
|
||||
for ( MavenProject mavenProject : analyzer.getRootSchedulableBuilds() )
|
||||
@ -136,7 +147,8 @@ private void multiThreadedProjectTaskSegmentBuild( ConcurrencyDependencyGraph an
|
||||
ProjectSegment projectSegment = projectBuildList.get( mavenProject );
|
||||
logger.debug( "Scheduling: " + projectSegment.getProject() );
|
||||
Callable<ProjectSegment> cb =
|
||||
createBuildCallable( rootSession, projectSegment, reactorContext, taskSegment, muxer );
|
||||
createBuildCallable( rootSession, projectSegment, reactorContext, taskSegment, muxer,
|
||||
duplicateArtifactIds );
|
||||
service.submit( cb );
|
||||
}
|
||||
|
||||
@ -161,7 +173,8 @@ private void multiThreadedProjectTaskSegmentBuild( ConcurrencyDependencyGraph an
|
||||
ProjectSegment scheduledDependent = projectBuildList.get( mavenProject );
|
||||
logger.debug( "Scheduling: " + scheduledDependent );
|
||||
Callable<ProjectSegment> cb =
|
||||
createBuildCallable( rootSession, scheduledDependent, reactorContext, taskSegment, muxer );
|
||||
createBuildCallable( rootSession, scheduledDependent, reactorContext, taskSegment, muxer,
|
||||
duplicateArtifactIds );
|
||||
service.submit( cb );
|
||||
}
|
||||
}
|
||||
@ -183,19 +196,26 @@ private void multiThreadedProjectTaskSegmentBuild( ConcurrencyDependencyGraph an
|
||||
private Callable<ProjectSegment> createBuildCallable( final MavenSession rootSession,
|
||||
final ProjectSegment projectBuild,
|
||||
final ReactorContext reactorContext,
|
||||
final TaskSegment taskSegment, final ThreadOutputMuxer muxer )
|
||||
final TaskSegment taskSegment,
|
||||
final ThreadOutputMuxer muxer,
|
||||
final Set<String> duplicateArtifactIds )
|
||||
{
|
||||
return () ->
|
||||
{
|
||||
final Thread currentThread = Thread.currentThread();
|
||||
final String originalThreadName = currentThread.getName();
|
||||
currentThread.setName( "mvn-builder-" + projectBuild.getProject().getId() );
|
||||
final MavenProject project = projectBuild.getProject();
|
||||
|
||||
final String threadNameSuffix = duplicateArtifactIds.contains( project.getArtifactId() )
|
||||
? project.getGroupId() + ":" + project.getArtifactId()
|
||||
: project.getArtifactId();
|
||||
currentThread.setName( "mvn-builder-" + threadNameSuffix );
|
||||
|
||||
try
|
||||
{
|
||||
// muxer.associateThreadWithProjectSegment( projectBuild );
|
||||
lifecycleModuleBuilder.buildProject( projectBuild.getSession(), rootSession, reactorContext,
|
||||
projectBuild.getProject(), taskSegment );
|
||||
lifecycleModuleBuilder.buildProject( projectBuild.getSession(), rootSession, reactorContext, project,
|
||||
taskSegment );
|
||||
// muxer.setThisModuleComplete( projectBuild );
|
||||
|
||||
return projectBuild;
|
||||
|
Loading…
x
Reference in New Issue
Block a user