digulla commented on a change in pull request #5: [MDEPLOY-206] Support
parallel deploy at end
URL: https://github.com/apache/maven-deploy-plugin/pull/5#discussion_r250987604
##########
File path: src/main/java/org/apache/maven/plugins/deploy/DeployMojo.java
##########
@@ -170,12 +183,71 @@ public void execute()
{
synchronized ( DEPLOYREQUESTS )
{
- while ( !DEPLOYREQUESTS.isEmpty() )
+ int requests = DEPLOYREQUESTS.size();
+ CompletionService<String> service = null;
+ if ( threads > 1 )
{
- ArtifactRepository repo = getDeploymentRepository(
DEPLOYREQUESTS.get( 0 ) );
+ service = new ExecutorCompletionService( new
ScheduledThreadPoolExecutor( threads ) );
+ getLog().info( "Deploying with " + threads + " threads" );
+ }
- deployProject( getSession().getProjectBuildingRequest(),
DEPLOYREQUESTS.remove( 0 ), repo );
+ for ( final ProjectDeployerRequest projectDeployerRequest :
DEPLOYREQUESTS )
+ {
+ Callable<String> callable = new Callable<String>()
+ {
+ @Override
+ public String call() throws Exception
+ {
+ ArtifactRepository repo = getDeploymentRepository(
projectDeployerRequest );
+ deployProject(
getSession().getProjectBuildingRequest(), projectDeployerRequest, repo );
+ return
projectDeployerRequest.getProject().getName();
+ }
+ };
+
+ if ( threads > 1 )
+ {
+ getLog().info( "Submitting " +
projectDeployerRequest.getProject().getName() );
+ service.submit( callable );
+ }
+ else
Review comment:
I'd create a similar service in Maven's support libraries. Being able to
switch freely between parallel and serial execution with the same code is
probably useful elsewhere (like running unit tests or reports).
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services