mirror of https://github.com/apache/maven.git
[MNG-6720] MultiThreadedBuilder: wait for parallel running projects when using --fail-fast
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 life cycle components that are needed for goal execution. This closes #272
This commit is contained in:
parent
dd0776d949
commit
0515cb1f0e
|
@ -27,7 +27,7 @@ import java.util.concurrent.ExecutionException;
|
||||||
import java.util.concurrent.ExecutorCompletionService;
|
import java.util.concurrent.ExecutorCompletionService;
|
||||||
import java.util.concurrent.ExecutorService;
|
import java.util.concurrent.ExecutorService;
|
||||||
import java.util.concurrent.Executors;
|
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.execution.MavenSession;
|
||||||
import org.apache.maven.lifecycle.internal.BuildThreadFactory;
|
import org.apache.maven.lifecycle.internal.BuildThreadFactory;
|
||||||
|
@ -114,6 +114,9 @@ public class MultiThreadedBuilder
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
executor.shutdown();
|
||||||
|
executor.awaitTermination( Long.MAX_VALUE, TimeUnit.MILLISECONDS );
|
||||||
}
|
}
|
||||||
|
|
||||||
private void multiThreadedProjectTaskSegmentBuild( ConcurrencyDependencyGraph analyzer,
|
private void multiThreadedProjectTaskSegmentBuild( ConcurrencyDependencyGraph analyzer,
|
||||||
|
@ -172,21 +175,6 @@ public class MultiThreadedBuilder
|
||||||
break;
|
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,
|
private Callable<ProjectSegment> createBuildCallable( final MavenSession rootSession,
|
||||||
|
|
Loading…
Reference in New Issue