You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by rf...@apache.org on 2013/10/05 18:34:11 UTC

svn commit: r1529478 - in /maven/plugins/trunk/maven-deploy-plugin/src: it/MDEPLOY-169_deploy-at-end-multithread/ it/MDEPLOY-169_deploy-at-end-multithread/module1/ it/MDEPLOY-169_deploy-at-end-multithread/module2/ main/java/org/apache/maven/plugin/deploy/

Author: rfscholte
Date: Sat Oct  5 16:34:10 2013
New Revision: 1529478

URL: http://svn.apache.org/r1529478
Log:
[MDEPLOY-169] deployAtEnd broken with parallel builds

Added:
    maven/plugins/trunk/maven-deploy-plugin/src/it/MDEPLOY-169_deploy-at-end-multithread/
    maven/plugins/trunk/maven-deploy-plugin/src/it/MDEPLOY-169_deploy-at-end-multithread/invoker.properties
    maven/plugins/trunk/maven-deploy-plugin/src/it/MDEPLOY-169_deploy-at-end-multithread/module1/
    maven/plugins/trunk/maven-deploy-plugin/src/it/MDEPLOY-169_deploy-at-end-multithread/module1/pom.xml
    maven/plugins/trunk/maven-deploy-plugin/src/it/MDEPLOY-169_deploy-at-end-multithread/module2/
    maven/plugins/trunk/maven-deploy-plugin/src/it/MDEPLOY-169_deploy-at-end-multithread/module2/pom.xml
    maven/plugins/trunk/maven-deploy-plugin/src/it/MDEPLOY-169_deploy-at-end-multithread/pom.xml
    maven/plugins/trunk/maven-deploy-plugin/src/it/MDEPLOY-169_deploy-at-end-multithread/verify.groovy
Modified:
    maven/plugins/trunk/maven-deploy-plugin/src/main/java/org/apache/maven/plugin/deploy/DeployMojo.java

Added: maven/plugins/trunk/maven-deploy-plugin/src/it/MDEPLOY-169_deploy-at-end-multithread/invoker.properties
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-deploy-plugin/src/it/MDEPLOY-169_deploy-at-end-multithread/invoker.properties?rev=1529478&view=auto
==============================================================================
--- maven/plugins/trunk/maven-deploy-plugin/src/it/MDEPLOY-169_deploy-at-end-multithread/invoker.properties (added)
+++ maven/plugins/trunk/maven-deploy-plugin/src/it/MDEPLOY-169_deploy-at-end-multithread/invoker.properties Sat Oct  5 16:34:10 2013
@@ -0,0 +1,18 @@
+# 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.goals = clean deploy -T2
+invoker.maven.version = 3.0+
\ No newline at end of file

Added: maven/plugins/trunk/maven-deploy-plugin/src/it/MDEPLOY-169_deploy-at-end-multithread/module1/pom.xml
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-deploy-plugin/src/it/MDEPLOY-169_deploy-at-end-multithread/module1/pom.xml?rev=1529478&view=auto
==============================================================================
--- maven/plugins/trunk/maven-deploy-plugin/src/it/MDEPLOY-169_deploy-at-end-multithread/module1/pom.xml (added)
+++ maven/plugins/trunk/maven-deploy-plugin/src/it/MDEPLOY-169_deploy-at-end-multithread/module1/pom.xml Sat Oct  5 16:34:10 2013
@@ -0,0 +1,25 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!-- 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. -->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+  <modelVersion>4.0.0</modelVersion>
+
+  <parent>
+    <groupId>org.apache.maven.its.mdeploy-169</groupId>
+    <artifactId>multithread</artifactId>
+    <version>1.0</version>
+  </parent>
+  <artifactId>module1</artifactId>
+
+</project>

Added: maven/plugins/trunk/maven-deploy-plugin/src/it/MDEPLOY-169_deploy-at-end-multithread/module2/pom.xml
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-deploy-plugin/src/it/MDEPLOY-169_deploy-at-end-multithread/module2/pom.xml?rev=1529478&view=auto
==============================================================================
--- maven/plugins/trunk/maven-deploy-plugin/src/it/MDEPLOY-169_deploy-at-end-multithread/module2/pom.xml (added)
+++ maven/plugins/trunk/maven-deploy-plugin/src/it/MDEPLOY-169_deploy-at-end-multithread/module2/pom.xml Sat Oct  5 16:34:10 2013
@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!-- 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. -->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+  <modelVersion>4.0.0</modelVersion>
+
+  <parent>
+    <groupId>org.apache.maven.its.mdeploy-169</groupId>
+    <artifactId>multithread</artifactId>
+    <version>1.0</version>
+  </parent>
+  <artifactId>module2</artifactId>
+  <packaging>pom</packaging>
+
+</project>

Added: maven/plugins/trunk/maven-deploy-plugin/src/it/MDEPLOY-169_deploy-at-end-multithread/pom.xml
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-deploy-plugin/src/it/MDEPLOY-169_deploy-at-end-multithread/pom.xml?rev=1529478&view=auto
==============================================================================
--- maven/plugins/trunk/maven-deploy-plugin/src/it/MDEPLOY-169_deploy-at-end-multithread/pom.xml (added)
+++ maven/plugins/trunk/maven-deploy-plugin/src/it/MDEPLOY-169_deploy-at-end-multithread/pom.xml Sat Oct  5 16:34:10 2013
@@ -0,0 +1,101 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+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.
+-->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+  <modelVersion>4.0.0</modelVersion>
+
+  <groupId>org.apache.maven.its.mdeploy-169</groupId>
+  <artifactId>multithread</artifactId>
+  <version>1.0</version>
+  <packaging>pom</packaging>
+
+  <description>
+    Tests deployment at end with two threads.
+  </description>
+
+  <properties>
+    <maven.test.skip>true</maven.test.skip>
+  </properties>
+
+  <distributionManagement>
+    <repository>
+      <id>it</id>
+      <url>file:///${basedir}/target/repo</url>
+      <uniqueVersion>false</uniqueVersion>
+    </repository>
+  </distributionManagement>
+
+  <build>
+    <plugins>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-compiler-plugin</artifactId>
+        <version>2.0.2</version>
+      </plugin>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-deploy-plugin</artifactId>
+        <version>@project.version@</version>
+        <configuration>
+          <deployAtEnd>true</deployAtEnd>
+        </configuration>
+      </plugin>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-install-plugin</artifactId>
+        <version>2.2</version>
+      </plugin>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-jar-plugin</artifactId>
+        <version>2.1</version>
+      </plugin>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-resources-plugin</artifactId>
+        <version>2.2</version>
+      </plugin>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-source-plugin</artifactId>
+        <version>2.0.4</version>
+        <executions>
+          <execution>
+            <id>attach-sources</id>
+            <goals>
+              <goal>jar</goal>
+            </goals>
+          </execution>
+        </executions>
+      </plugin>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-surefire-plugin</artifactId>
+        <version>2.3.1</version>
+      </plugin>
+    </plugins>
+  </build>
+
+  <modules>
+    <module>module1</module>
+    <module>module2</module>
+  </modules>
+</project>

Added: maven/plugins/trunk/maven-deploy-plugin/src/it/MDEPLOY-169_deploy-at-end-multithread/verify.groovy
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-deploy-plugin/src/it/MDEPLOY-169_deploy-at-end-multithread/verify.groovy?rev=1529478&view=auto
==============================================================================
--- maven/plugins/trunk/maven-deploy-plugin/src/it/MDEPLOY-169_deploy-at-end-multithread/verify.groovy (added)
+++ maven/plugins/trunk/maven-deploy-plugin/src/it/MDEPLOY-169_deploy-at-end-multithread/verify.groovy Sat Oct  5 16:34:10 2013
@@ -0,0 +1,22 @@
+/*
+ * 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( basedir, "target/repo/org/apache/maven/its/mdeploy-169/multithread/1.0/multithread-1.0.pom" ).exists()
+assert new File( basedir, "module1/target/repo/org/apache/maven/its/mdeploy-169/module1/1.0/module1-1.0.pom" ).exists()
+assert new File( basedir, "module2/target/repo/org/apache/maven/its/mdeploy-169/module2/1.0/module2-1.0.pom" ).exists()

Modified: maven/plugins/trunk/maven-deploy-plugin/src/main/java/org/apache/maven/plugin/deploy/DeployMojo.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-deploy-plugin/src/main/java/org/apache/maven/plugin/deploy/DeployMojo.java?rev=1529478&r1=1529477&r2=1529478&view=diff
==============================================================================
--- maven/plugins/trunk/maven-deploy-plugin/src/main/java/org/apache/maven/plugin/deploy/DeployMojo.java (original)
+++ maven/plugins/trunk/maven-deploy-plugin/src/main/java/org/apache/maven/plugin/deploy/DeployMojo.java Sat Oct  5 16:34:10 2013
@@ -36,6 +36,7 @@ import org.apache.maven.project.artifact
 
 import java.io.File;
 import java.util.List;
+import java.util.concurrent.atomic.AtomicInteger;
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
 
@@ -52,6 +53,11 @@ public class DeployMojo
 {
 
     private static final Pattern ALT_REPO_SYNTAX_PATTERN = Pattern.compile( "(.+)::(.+)::(.+)" );
+    
+    /**
+     * When building with multiple threads, reaching the last project doesn't have to mean that all projects are ready to be deployed 
+     */
+    private static final AtomicInteger readyProjectsCounter = new AtomicInteger();
 
     /**
      */
@@ -140,6 +146,8 @@ public class DeployMojo
     public void execute()
         throws MojoExecutionException, MojoFailureException
     {
+        int projectsReady = readyProjectsCounter.incrementAndGet();
+        
         if ( skip )
         {
             getLog().info( "Skipping artifact deployment" );
@@ -152,20 +160,16 @@ public class DeployMojo
         {
             deployProject( project );
         }
+        else if ( projectsReady < reactorProjects.size() )
+        {
+            getLog().info( "Deploying " + project.getGroupId() + ":" + project.getArtifactId() + ":"
+                               + project.getVersion() + " at end" );
+        }
         else
         {
-            MavenProject lastProject = reactorProjects.get( reactorProjects.size() - 1 );
-            if ( lastProject.equals( project ) )
-            {
-                for ( MavenProject reactorProject : reactorProjects )
-                {
-                    deployProject( reactorProject );
-                }
-            }
-            else
+            for ( MavenProject reactorProject : reactorProjects )
             {
-                getLog().info( "Deploying " + project.getGroupId() + ":" + project.getArtifactId() + ":"
-                                   + project.getVersion() + " at end" );
+                deployProject( reactorProject );
             }
         }
     }