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/04 22:40:14 UTC

svn commit: r1529287 - in /maven/plugins/trunk/maven-install-plugin/src: it/MINSTALL-98/ it/MINSTALL-98/module1/ it/MINSTALL-98/module2/ main/java/org/apache/maven/plugin/install/

Author: rfscholte
Date: Fri Oct  4 20:40:14 2013
New Revision: 1529287

URL: http://svn.apache.org/r1529287
Log:
[MINSTALL-98] installAtEnd broken with parallel builds 

Added:
    maven/plugins/trunk/maven-install-plugin/src/it/MINSTALL-98/
    maven/plugins/trunk/maven-install-plugin/src/it/MINSTALL-98/invoker.properties
    maven/plugins/trunk/maven-install-plugin/src/it/MINSTALL-98/module1/
    maven/plugins/trunk/maven-install-plugin/src/it/MINSTALL-98/module1/pom.xml
    maven/plugins/trunk/maven-install-plugin/src/it/MINSTALL-98/module2/
    maven/plugins/trunk/maven-install-plugin/src/it/MINSTALL-98/module2/pom.xml
    maven/plugins/trunk/maven-install-plugin/src/it/MINSTALL-98/pom.xml
    maven/plugins/trunk/maven-install-plugin/src/it/MINSTALL-98/verify.groovy
Modified:
    maven/plugins/trunk/maven-install-plugin/src/main/java/org/apache/maven/plugin/install/InstallMojo.java

Added: maven/plugins/trunk/maven-install-plugin/src/it/MINSTALL-98/invoker.properties
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-install-plugin/src/it/MINSTALL-98/invoker.properties?rev=1529287&view=auto
==============================================================================
--- maven/plugins/trunk/maven-install-plugin/src/it/MINSTALL-98/invoker.properties (added)
+++ maven/plugins/trunk/maven-install-plugin/src/it/MINSTALL-98/invoker.properties Fri Oct  4 20:40:14 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 install -T2
+invoker.maven.version = 3.0+
\ No newline at end of file

Added: maven/plugins/trunk/maven-install-plugin/src/it/MINSTALL-98/module1/pom.xml
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-install-plugin/src/it/MINSTALL-98/module1/pom.xml?rev=1529287&view=auto
==============================================================================
--- maven/plugins/trunk/maven-install-plugin/src/it/MINSTALL-98/module1/pom.xml (added)
+++ maven/plugins/trunk/maven-install-plugin/src/it/MINSTALL-98/module1/pom.xml Fri Oct  4 20:40:14 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.minstall-98</groupId>
+    <artifactId>multithread</artifactId>
+    <version>1.0</version>
+  </parent>
+  <artifactId>module1</artifactId>
+
+</project>

Added: maven/plugins/trunk/maven-install-plugin/src/it/MINSTALL-98/module2/pom.xml
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-install-plugin/src/it/MINSTALL-98/module2/pom.xml?rev=1529287&view=auto
==============================================================================
--- maven/plugins/trunk/maven-install-plugin/src/it/MINSTALL-98/module2/pom.xml (added)
+++ maven/plugins/trunk/maven-install-plugin/src/it/MINSTALL-98/module2/pom.xml Fri Oct  4 20:40:14 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.minstall-98</groupId>
+    <artifactId>multithread</artifactId>
+    <version>1.0</version>
+  </parent>
+  <artifactId>module2</artifactId>
+  <packaging>pom</packaging>
+
+</project>

Added: maven/plugins/trunk/maven-install-plugin/src/it/MINSTALL-98/pom.xml
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-install-plugin/src/it/MINSTALL-98/pom.xml?rev=1529287&view=auto
==============================================================================
--- maven/plugins/trunk/maven-install-plugin/src/it/MINSTALL-98/pom.xml (added)
+++ maven/plugins/trunk/maven-install-plugin/src/it/MINSTALL-98/pom.xml Fri Oct  4 20:40:14 2013
@@ -0,0 +1,77 @@
+<?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.minstall-98</groupId>
+  <artifactId>multithread</artifactId>
+  <version>1.0</version>
+  <packaging>pom</packaging>
+
+  <description>
+    Tests installation at end with two threads.
+  </description>
+
+  <properties>
+    <maven.test.skip>true</maven.test.skip>
+  </properties>
+
+  <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-install-plugin</artifactId>
+        <version>@project.version@</version>
+        <configuration>
+          <installAtEnd>true</installAtEnd>
+        </configuration>
+      </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-surefire-plugin</artifactId>
+        <version>2.12</version>
+      </plugin>
+    </plugins>
+  </build>
+
+  <modules>
+    <module>module1</module>
+    <module>module2</module>
+  </modules>
+
+</project>

Added: maven/plugins/trunk/maven-install-plugin/src/it/MINSTALL-98/verify.groovy
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-install-plugin/src/it/MINSTALL-98/verify.groovy?rev=1529287&view=auto
==============================================================================
--- maven/plugins/trunk/maven-install-plugin/src/it/MINSTALL-98/verify.groovy (added)
+++ maven/plugins/trunk/maven-install-plugin/src/it/MINSTALL-98/verify.groovy Fri Oct  4 20:40:14 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, "../../local-repo/org/apache/maven/its/minstall-98/multithread/1.0/multithread-1.0.pom" ).exists()
+assert new File( basedir, "../../local-repo/org/apache/maven/its/minstall-98/module1/1.0/module1-1.0.pom" ).exists()
+assert new File( basedir, "../../local-repo/org/apache/maven/its/minstall-98/module2/1.0/module2-1.0.pom" ).exists()

Modified: maven/plugins/trunk/maven-install-plugin/src/main/java/org/apache/maven/plugin/install/InstallMojo.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-install-plugin/src/main/java/org/apache/maven/plugin/install/InstallMojo.java?rev=1529287&r1=1529286&r2=1529287&view=diff
==============================================================================
--- maven/plugins/trunk/maven-install-plugin/src/main/java/org/apache/maven/plugin/install/InstallMojo.java (original)
+++ maven/plugins/trunk/maven-install-plugin/src/main/java/org/apache/maven/plugin/install/InstallMojo.java Fri Oct  4 20:40:14 2013
@@ -23,6 +23,7 @@ import java.io.File;
 import java.util.Collection;
 import java.util.LinkedHashSet;
 import java.util.List;
+import java.util.concurrent.atomic.AtomicInteger;
 
 import org.apache.maven.artifact.Artifact;
 import org.apache.maven.artifact.installer.ArtifactInstallationException;
@@ -48,6 +49,11 @@ public class InstallMojo
 {
 
     /**
+     * When building with multiple threads, reaching the last project doesn't have to mean that all projects are ready to be installed 
+     */
+    private static final AtomicInteger readyProjectsCounter = new AtomicInteger(); 
+
+    /**
      */
     @Component
     private MavenProject project;
@@ -113,8 +119,7 @@ public class InstallMojo
         }
         else
         {
-            MavenProject lastProject = reactorProjects.get( reactorProjects.size() - 1 );
-            if ( lastProject.equals( project ) )
+            if ( readyProjectsCounter.incrementAndGet() == reactorProjects.size() )
             {
                 for ( MavenProject reactorProject : reactorProjects )
                 {