diff --git a/src/it/MDEPLOY-224_deploy-at-end-only-modules/verify.groovy b/src/it/MDEPLOY-224_deploy-at-end-only-modules/verify.groovy index ee4e5e75..063f2aee 100644 --- a/src/it/MDEPLOY-224_deploy-at-end-only-modules/verify.groovy +++ b/src/it/MDEPLOY-224_deploy-at-end-only-modules/verify.groovy @@ -25,4 +25,5 @@ def buildLog = new File ( basedir, "build.log").text assert ! buildLog.contains('[INFO] Deferring deploy for org.apache.maven.its.mdeploy-224:parent:1.0 at end') assert buildLog.contains('[INFO] Deferring deploy for org.apache.maven.its.mdeploy-224:module1:1.0 at end') -assert buildLog.contains('[INFO] Deferring deploy for org.apache.maven.its.mdeploy-224:module2:1.0 at end') +// Last module does not emit this misleading message, as it IS "the end", not deferring anymore +// assert buildLog.contains('[INFO] Deferring deploy for org.apache.maven.its.mdeploy-224:module2:1.0 at end') diff --git a/src/it/deploy-at-end-parallel/invoker.properties b/src/it/deploy-at-end-parallel/invoker.properties deleted file mode 100644 index 4a11915f..00000000 --- a/src/it/deploy-at-end-parallel/invoker.properties +++ /dev/null @@ -1,18 +0,0 @@ -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - -invoker.mavenOpts = -Dorg.slf4j.simpleLogger.showThreadName=true \ No newline at end of file diff --git a/src/it/deploy-at-end-parallel/module1/pom.xml b/src/it/deploy-at-end-parallel/module1/pom.xml deleted file mode 100644 index 4466ec7d..00000000 --- a/src/it/deploy-at-end-parallel/module1/pom.xml +++ /dev/null @@ -1,25 +0,0 @@ - - - - - - 4.0.0 - - - org.apache.maven.its.deploy.dae.parallel - dae - 1.0 - - module1 - - diff --git a/src/it/deploy-at-end-parallel/module2/pom.xml b/src/it/deploy-at-end-parallel/module2/pom.xml deleted file mode 100644 index d38b6718..00000000 --- a/src/it/deploy-at-end-parallel/module2/pom.xml +++ /dev/null @@ -1,25 +0,0 @@ - - - - - - 4.0.0 - - - org.apache.maven.its.deploy.dae.parallel - dae - 1.0 - - module2 - - diff --git a/src/it/deploy-at-end-parallel/module3/pom.xml b/src/it/deploy-at-end-parallel/module3/pom.xml deleted file mode 100644 index be6d3437..00000000 --- a/src/it/deploy-at-end-parallel/module3/pom.xml +++ /dev/null @@ -1,25 +0,0 @@ - - - - - - 4.0.0 - - - org.apache.maven.its.deploy.dae.parallel - dae - 1.0 - - module3 - - diff --git a/src/it/deploy-at-end-parallel/module4/pom.xml b/src/it/deploy-at-end-parallel/module4/pom.xml deleted file mode 100644 index a3d83823..00000000 --- a/src/it/deploy-at-end-parallel/module4/pom.xml +++ /dev/null @@ -1,25 +0,0 @@ - - - - - - 4.0.0 - - - org.apache.maven.its.deploy.dae.parallel - dae - 1.0 - - module4 - - diff --git a/src/it/deploy-at-end-parallel/pom.xml b/src/it/deploy-at-end-parallel/pom.xml deleted file mode 100644 index 3e783511..00000000 --- a/src/it/deploy-at-end-parallel/pom.xml +++ /dev/null @@ -1,103 +0,0 @@ - - - - - - 4.0.0 - - org.apache.maven.its.deploy.dae.parallel - dae - 1.0 - pom - - - Tests deployment at end with parallel. - - - - true - - - - - it - file:///@remoteRepo@/deploy-at-end-parallel - - - - - - - org.apache.maven.plugins - maven-compiler-plugin - @mavenCompilerPluginVersion@ - - - org.apache.maven.plugins - maven-deploy-plugin - @project.version@ - - true - 4 - - - - org.apache.maven.plugins - maven-install-plugin - @mavenInstallPluginVersion@ - - - org.apache.maven.plugins - maven-jar-plugin - @mavenJarPluginVersion@ - - - org.apache.maven.plugins - maven-resources-plugin - @mavenResourcesPluginVersion@ - - - org.apache.maven.plugins - maven-source-plugin - @mavenSourcePluginVersion@ - - - attach-sources - - jar - - - - - - org.apache.maven.plugins - maven-surefire-plugin - @mavenSurefirePluginVersion@ - - - - - - module1 - module2 - module3 - module4 - - diff --git a/src/it/deploy-at-end-parallel/setup.groovy b/src/it/deploy-at-end-parallel/setup.groovy deleted file mode 100644 index 3fd36199..00000000 --- a/src/it/deploy-at-end-parallel/setup.groovy +++ /dev/null @@ -1,26 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - - -def mockrepo = new File( remoteRepo, "deploy-at-end-parallel") -mockrepo.deleteDir() - -assert !mockrepo.exists() - -mockrepo.mkdirs() \ No newline at end of file diff --git a/src/it/deploy-at-end-parallel/verify.groovy b/src/it/deploy-at-end-parallel/verify.groovy deleted file mode 100644 index 845a6951..00000000 --- a/src/it/deploy-at-end-parallel/verify.groovy +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -assert new File( remoteRepo, "deploy-at-end-parallel/org/apache/maven/its/deploy/dae/parallel/dae/1.0/dae-1.0.pom" ).exists() -assert new File( remoteRepo, "deploy-at-end-parallel/org/apache/maven/its/deploy/dae/parallel/module1/1.0/module1-1.0.pom" ).exists() -assert new File( remoteRepo, "deploy-at-end-parallel/org/apache/maven/its/deploy/dae/parallel/module1/1.0/module1-1.0.jar" ).exists() -assert new File( remoteRepo, "deploy-at-end-parallel/org/apache/maven/its/deploy/dae/parallel/module2/1.0/module2-1.0.pom" ).exists() -assert new File( remoteRepo, "deploy-at-end-parallel/org/apache/maven/its/deploy/dae/parallel/module2/1.0/module2-1.0.jar" ).exists() -assert new File( remoteRepo, "deploy-at-end-parallel/org/apache/maven/its/deploy/dae/parallel/module3/1.0/module3-1.0.pom" ).exists() -assert new File( remoteRepo, "deploy-at-end-parallel/org/apache/maven/its/deploy/dae/parallel/module3/1.0/module3-1.0.jar" ).exists() -assert new File( remoteRepo, "deploy-at-end-parallel/org/apache/maven/its/deploy/dae/parallel/module4/1.0/module4-1.0.pom" ).exists() -assert new File( remoteRepo, "deploy-at-end-parallel/org/apache/maven/its/deploy/dae/parallel/module4/1.0/module4-1.0.jar" ).exists() - -File buildLog = new File( basedir, 'build.log' ) -assert buildLog.exists() -assert buildLog.text.contains( "[INFO] Deferring deploy for org.apache.maven.its.deploy.dae.parallel:dae:1.0 at end" ) -assert buildLog.text.contains( "[INFO] Deferring deploy for org.apache.maven.its.deploy.dae.parallel:module1:1.0 at end" ) -assert buildLog.text.contains( "[INFO] Deferring deploy for org.apache.maven.its.deploy.dae.parallel:module2:1.0 at end" ) -assert buildLog.text.contains( "[INFO] Deferring deploy for org.apache.maven.its.deploy.dae.parallel:module3:1.0 at end" ) -assert buildLog.text.contains( "[INFO] Deferring deploy for org.apache.maven.its.deploy.dae.parallel:module4:1.0 at end" ) - diff --git a/src/it/deploy-at-end-pass/verify.groovy b/src/it/deploy-at-end-pass/verify.groovy index 6aedbb57..8db44909 100644 --- a/src/it/deploy-at-end-pass/verify.groovy +++ b/src/it/deploy-at-end-pass/verify.groovy @@ -27,5 +27,6 @@ File buildLog = new File( basedir, 'build.log' ) assert buildLog.exists() assert buildLog.text.contains( "[INFO] Deferring deploy for org.apache.maven.its.deploy.dae.pass:dae:1.0 at end" ) assert buildLog.text.contains( "[INFO] Deferring deploy for org.apache.maven.its.deploy.dae.pass:module1:1.0 at end" ) -assert buildLog.text.contains( "[INFO] Deferring deploy for org.apache.maven.its.deploy.dae.pass:module3:1.0 at end" ) +// Last module does not emit this misleading message, as it IS "the end", not deferring anymore +//assert buildLog.text.contains( "[INFO] Deferring deploy for org.apache.maven.its.deploy.dae.pass:module3:1.0 at end" ) diff --git a/src/main/java/org/apache/maven/plugins/deploy/DeployMojo.java b/src/main/java/org/apache/maven/plugins/deploy/DeployMojo.java index 98d5ee99..4e317acf 100644 --- a/src/main/java/org/apache/maven/plugins/deploy/DeployMojo.java +++ b/src/main/java/org/apache/maven/plugins/deploy/DeployMojo.java @@ -23,10 +23,6 @@ import java.util.LinkedHashMap; import java.util.List; import java.util.Map; -import java.util.concurrent.Callable; -import java.util.concurrent.ExecutorService; -import java.util.concurrent.Executors; -import java.util.concurrent.atomic.AtomicBoolean; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -75,14 +71,6 @@ public class DeployMojo extends AbstractDeployMojo { @Parameter(defaultValue = "false", property = "deployAtEnd") private boolean deployAtEnd; - /** - * The number of parallel threads which will be used for deployment with the {@code deployAtEnd} feature. - * - * @since 3.1.0 - */ - @Parameter(property = "maven.deploy.parallelThreads", defaultValue = "1") - private int parallelThreads; - /** * Specifies an alternative repository to which the project artifacts should be deployed (other than those specified * in <distributionManagement>).
@@ -179,11 +167,12 @@ private boolean hasState(MavenProject project) { } public void execute() throws MojoExecutionException, MojoFailureException { + State state; if (Boolean.parseBoolean(skip) || ("releases".equals(skip) && !ArtifactUtils.isSnapshot(project.getVersion())) || ("snapshots".equals(skip) && ArtifactUtils.isSnapshot(project.getVersion()))) { getLog().info("Skipping artifact deployment"); - putState(State.SKIPPED); + state = State.SKIPPED; } else { failIfOffline(); warnIfAffectedPackagingAndMaven(project.getPackaging()); @@ -200,25 +189,24 @@ public void execute() throws MojoExecutionException, MojoFailureException { request.setRepository(deploymentRepository); processProject(project, request); deploy(request); - putState(State.DEPLOYED); + state = State.DEPLOYED; } else { putPluginContextValue(DEPLOY_ALT_SNAPSHOT_DEPLOYMENT_REPOSITORY, altSnapshotDeploymentRepository); putPluginContextValue(DEPLOY_ALT_RELEASE_DEPLOYMENT_REPOSITORY, altReleaseDeploymentRepository); putPluginContextValue(DEPLOY_ALT_DEPLOYMENT_REPOSITORY, altDeploymentRepository); - putState(State.TO_BE_DEPLOYED); - getLog().info("Deferring deploy for " + project.getGroupId() + ":" + project.getArtifactId() + ":" - + project.getVersion() + " at end"); + state = State.TO_BE_DEPLOYED; } } + putState(state); + List allProjectsUsingPlugin = getAllProjectsUsingPlugin(); if (allProjectsMarked(allProjectsUsingPlugin)) { - if (parallelThreads <= 1) { - deployAllAtOnce(allProjectsUsingPlugin); - } else { - deployInParallel(allProjectsUsingPlugin); - } + deployAllAtOnce(allProjectsUsingPlugin); + } else if (state == State.TO_BE_DEPLOYED) { + getLog().info("Deferring deploy for " + project.getGroupId() + ":" + project.getArtifactId() + ":" + + project.getVersion() + " at end"); } } @@ -252,59 +240,6 @@ private void deployAllAtOnce(List allProjectsUsingPlugin) throws M } } - private void deployInParallel(List allProjectsUsingPlugin) throws MojoExecutionException { - - List> requestTasks = new ArrayList<>(); - AtomicBoolean hasError = new AtomicBoolean(false); - - for (MavenProject reactorProject : allProjectsUsingPlugin) { - Map pluginContext = session.getPluginContext(pluginDescriptor, reactorProject); - State state = getState(pluginContext); - if (state == State.TO_BE_DEPLOYED) { - - RemoteRepository deploymentRepository = getDeploymentRepository( - reactorProject, - getPluginContextValue(pluginContext, DEPLOY_ALT_SNAPSHOT_DEPLOYMENT_REPOSITORY), - getPluginContextValue(pluginContext, DEPLOY_ALT_RELEASE_DEPLOYMENT_REPOSITORY), - getPluginContextValue(pluginContext, DEPLOY_ALT_DEPLOYMENT_REPOSITORY)); - - DeployRequest request = new DeployRequest(); - request.setRepository(deploymentRepository); - - processProject(reactorProject, request); - - requestTasks.add(() -> { - try { - if (!hasError.get()) { - deploy(request); - } - } catch (MojoExecutionException e) { - hasError.set(true); - getLog().error(e.getMessage(), e); - } - return null; - }); - } - } - - if (!requestTasks.isEmpty()) { - ExecutorService executorService = Executors.newFixedThreadPool(parallelThreads); - - try { - executorService.invokeAll(requestTasks); - } catch (InterruptedException e) { - Thread.currentThread().interrupt(); - throw new MojoExecutionException(e.getMessage(), e); - } - - executorService.shutdown(); - - if (hasError.get()) { - throw new MojoExecutionException("Deployment errors"); - } - } - } - private boolean allProjectsMarked(List allProjectsUsingPlugin) { for (MavenProject reactorProject : allProjectsUsingPlugin) { if (!hasState(reactorProject)) {