Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[MNG-6774] - Speedup project graph build by paralleling operations #290

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,15 @@

import java.io.File;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.Iterator;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ForkJoinPool;
import java.util.concurrent.ForkJoinTask;

import org.apache.maven.DefaultMaven;
import org.apache.maven.MavenExecutionException;
Expand Down Expand Up @@ -401,18 +402,42 @@ private List<MavenProject> getProjectsForMavenReactor( MavenSession session )
return projects;
}

List<File> files = Arrays.asList( request.getPom().getAbsoluteFile() );
List<File> files = Collections.singletonList( request.getPom().getAbsoluteFile() );
collectProjects( projects, files, request );
return projects;
}

private void collectProjects( List<MavenProject> projects, List<File> files, MavenExecutionRequest request )
throws ProjectBuildingException
private void collectProjects( List<MavenProject> projects, final List<File> files,
final MavenExecutionRequest request ) throws ProjectBuildingException
{
ProjectBuildingRequest projectBuildingRequest = request.getProjectBuildingRequest();
final ProjectBuildingRequest projectBuildingRequest = request.getProjectBuildingRequest();

long start = System.currentTimeMillis();

List<ProjectBuildingResult> results;
if ( request.getDegreeOfConcurrency() <= 1 || Boolean.getBoolean( "maven.concurrentGraph.disable" ) )
AlexanderAshitkin marked this conversation as resolved.
Show resolved Hide resolved
{
results = projectBuilder.build( files, request.isRecursive(), projectBuildingRequest );
}
else
{
ForkJoinPool fjp = new ForkJoinPool( request.getDegreeOfConcurrency() );
try
{

List<ProjectBuildingResult> results = projectBuilder.build( files, request.isRecursive(),
projectBuildingRequest );
results = fjp.invoke( ForkJoinTask.adapt(
() -> projectBuilder.build( files, request.isRecursive(), projectBuildingRequest ) ) );
}
finally
{
fjp.shutdown();
}
}

if ( logger.isDebugEnabled() )
{
logger.debug( "Project graph built in " + ( System.currentTimeMillis() - start ) + " millis." );
}

boolean problems = false;

Expand Down
Loading