Skip to content

Commit

Permalink
[MNG-6720] - Wait for parallel projects when using --fail-fast
Browse files Browse the repository at this point in the history
Otherwise the sessionFinished event may be sent before some
projects/goals finish, which violates the contracts of execution
listeners and makes it hard to properly lifecycle components that
are needed for goal execution.
  • Loading branch information
oehme authored and jschwartzenberg committed Jul 25, 2019
1 parent e3de2b1 commit b26c0f5
Showing 1 changed file with 4 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
import java.util.concurrent.ExecutorCompletionService;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;
import java.util.concurrent.TimeUnit;

import org.apache.maven.execution.MavenSession;
import org.apache.maven.lifecycle.internal.BuildThreadFactory;
Expand Down Expand Up @@ -114,6 +114,9 @@ public void build( MavenSession session, ReactorContext reactorContext, ProjectB
}

}

executor.shutdown();
executor.awaitTermination( Long.MAX_VALUE, TimeUnit.MILLISECONDS );
}

private void multiThreadedProjectTaskSegmentBuild( ConcurrencyDependencyGraph analyzer,
Expand Down Expand Up @@ -172,21 +175,6 @@ private void multiThreadedProjectTaskSegmentBuild( ConcurrencyDependencyGraph an
break;
}
}

// cancel outstanding builds (if any) - this can happen if an exception is thrown in above block

Future<ProjectSegment> unprocessed;
while ( ( unprocessed = service.poll() ) != null )
{
try
{
unprocessed.get();
}
catch ( InterruptedException | ExecutionException e )
{
throw new RuntimeException( e );
}
}
}

private Callable<ProjectSegment> createBuildCallable( final MavenSession rootSession,
Expand Down

0 comments on commit b26c0f5

Please sign in to comment.