maven-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ol...@apache.org
Subject [maven-invoker-plugin] branch master updated: Fix MINVOKER-191 (#1)
Date Wed, 28 Mar 2018 05:49:04 GMT
This is an automated email from the ASF dual-hosted git repository.

olamy pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/maven-invoker-plugin.git


The following commit(s) were added to refs/heads/master by this push:
     new 0136f83  Fix  MINVOKER-191 (#1)
0136f83 is described below

commit 0136f8395ae9c98b6c1818fb516d13002ec6bc1f
Author: Olivier Lamy <olamy@apache.org>
AuthorDate: Wed Mar 28 15:49:01 2018 +1000

    Fix  MINVOKER-191 (#1)
    
    * [MINVOKER-191] only install direct references project
    
    Signed-off-by: olivier lamy <olamy@apache.org>
    
    * fix wrong test, it test module depends on the plugin module so definitely needs to be
declared as a dependency and build first
    
    Signed-off-by: olivier lamy <olamy@apache.org>
---
 src/it/MINVOKER-191/invoker.properties             | 18 +++++
 .../itests => MINVOKER-191/module-a}/pom.xml       | 34 +++-------
 .../java/org/apache/maven/plugins/foo/Hello.java   | 28 ++++++++
 .../org/apache/maven/plugins/foo/HelloTest.java    | 32 +++++++++
 .../itests => MINVOKER-191/module-b}/pom.xml       | 34 +++-------
 .../java/org/apache/maven/plugins/foo/Hello.java   | 28 ++++++++
 .../org/apache/maven/plugins/foo/HelloTest.java    | 32 +++++++++
 .../itests => MINVOKER-191/plugin}/pom.xml         | 14 +++-
 .../plugin/src/it/basic}/pom.xml                   | 23 +++----
 .../org/apache/maven/it/plugins/dummy/MyMojo.java  | 78 ++++++++++++++++++++++
 src/it/MINVOKER-191/pom.xml                        | 72 ++++++++++++++++++++
 src/it/invocation-reactor-indirect/itests/pom.xml  |  8 +++
 .../apache/maven/plugins/invoker/InstallMojo.java  | 22 +++++-
 13 files changed, 354 insertions(+), 69 deletions(-)

diff --git a/src/it/MINVOKER-191/invoker.properties b/src/it/MINVOKER-191/invoker.properties
new file mode 100644
index 0000000..332fb68
--- /dev/null
+++ b/src/it/MINVOKER-191/invoker.properties
@@ -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 -T3
diff --git a/src/it/invocation-reactor-indirect/itests/pom.xml b/src/it/MINVOKER-191/module-a/pom.xml
similarity index 61%
copy from src/it/invocation-reactor-indirect/itests/pom.xml
copy to src/it/MINVOKER-191/module-a/pom.xml
index bcf529f..942b5b3 100644
--- a/src/it/invocation-reactor-indirect/itests/pom.xml
+++ b/src/it/MINVOKER-191/module-a/pom.xml
@@ -24,31 +24,17 @@ under the License.
   <modelVersion>4.0.0</modelVersion>
   <parent>
     <groupId>org.apache.maven.plugins.invoker</groupId>
-    <artifactId>MINVOKER-115-parent</artifactId>
+    <artifactId>MINVOKER-191-parent</artifactId>
     <version>1.0-SNAPSHOT</version>
   </parent>
-  <artifactId>MINVOKER-115-itests</artifactId>
-  <packaging>pom</packaging>
+  <artifactId>MINVOKER-191-java-a</artifactId>
+
+  <dependencies>
+    <dependency>
+      <groupId>junit</groupId>
+      <artifactId>junit</artifactId>
+      <version>4.12</version>
+    </dependency>
+  </dependencies>
 
-  <build>
-    <plugins>
-      <plugin>
-        <groupId>org.apache.maven.plugins</groupId>
-        <artifactId>maven-invoker-plugin</artifactId>
-        <configuration>
-          <cloneProjectsTo>${project.build.directory}/it</cloneProjectsTo>
-          <localRepositoryPath>${project.build.directory}/local-repo</localRepositoryPath>
-        </configuration>
-        <executions>
-          <execution>
-            <id>itests</id>
-            <goals>
-              <goal>install</goal>
-              <goal>run</goal>
-            </goals>
-          </execution>
-        </executions>
-      </plugin>
-    </plugins>
-  </build>
 </project>
diff --git a/src/it/MINVOKER-191/module-a/src/main/java/org/apache/maven/plugins/foo/Hello.java
b/src/it/MINVOKER-191/module-a/src/main/java/org/apache/maven/plugins/foo/Hello.java
new file mode 100644
index 0000000..b235be8
--- /dev/null
+++ b/src/it/MINVOKER-191/module-a/src/main/java/org/apache/maven/plugins/foo/Hello.java
@@ -0,0 +1,28 @@
+package org.apache.maven.plugins.foo;
+
+/*
+ * 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.
+ */
+
+public class Hello {
+
+    public static String sayHello(String who) throws Exception {
+        return "Hello " + who;
+    }
+
+}
\ No newline at end of file
diff --git a/src/it/MINVOKER-191/module-a/src/test/java/org/apache/maven/plugins/foo/HelloTest.java
b/src/it/MINVOKER-191/module-a/src/test/java/org/apache/maven/plugins/foo/HelloTest.java
new file mode 100644
index 0000000..ea1e4ff
--- /dev/null
+++ b/src/it/MINVOKER-191/module-a/src/test/java/org/apache/maven/plugins/foo/HelloTest.java
@@ -0,0 +1,32 @@
+package org.apache.maven.plugins.foo;
+
+/*
+ * 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.
+ */
+
+import org.junit.Test;
+
+public class HelloTest {
+
+    @Test
+    public void say_hello_test() throws Exception {
+        Hello.sayHello("foo");
+        Thread.sleep(4000);
+    }
+
+}
\ No newline at end of file
diff --git a/src/it/invocation-reactor-indirect/itests/pom.xml b/src/it/MINVOKER-191/module-b/pom.xml
similarity index 61%
copy from src/it/invocation-reactor-indirect/itests/pom.xml
copy to src/it/MINVOKER-191/module-b/pom.xml
index bcf529f..46cfd92 100644
--- a/src/it/invocation-reactor-indirect/itests/pom.xml
+++ b/src/it/MINVOKER-191/module-b/pom.xml
@@ -24,31 +24,17 @@ under the License.
   <modelVersion>4.0.0</modelVersion>
   <parent>
     <groupId>org.apache.maven.plugins.invoker</groupId>
-    <artifactId>MINVOKER-115-parent</artifactId>
+    <artifactId>MINVOKER-191-parent</artifactId>
     <version>1.0-SNAPSHOT</version>
   </parent>
-  <artifactId>MINVOKER-115-itests</artifactId>
-  <packaging>pom</packaging>
+  <artifactId>MINVOKER-191-java-b</artifactId>
+
+  <dependencies>
+    <dependency>
+      <groupId>junit</groupId>
+      <artifactId>junit</artifactId>
+      <version>4.12</version>
+    </dependency>
+  </dependencies>
 
-  <build>
-    <plugins>
-      <plugin>
-        <groupId>org.apache.maven.plugins</groupId>
-        <artifactId>maven-invoker-plugin</artifactId>
-        <configuration>
-          <cloneProjectsTo>${project.build.directory}/it</cloneProjectsTo>
-          <localRepositoryPath>${project.build.directory}/local-repo</localRepositoryPath>
-        </configuration>
-        <executions>
-          <execution>
-            <id>itests</id>
-            <goals>
-              <goal>install</goal>
-              <goal>run</goal>
-            </goals>
-          </execution>
-        </executions>
-      </plugin>
-    </plugins>
-  </build>
 </project>
diff --git a/src/it/MINVOKER-191/module-b/src/main/java/org/apache/maven/plugins/foo/Hello.java
b/src/it/MINVOKER-191/module-b/src/main/java/org/apache/maven/plugins/foo/Hello.java
new file mode 100644
index 0000000..b235be8
--- /dev/null
+++ b/src/it/MINVOKER-191/module-b/src/main/java/org/apache/maven/plugins/foo/Hello.java
@@ -0,0 +1,28 @@
+package org.apache.maven.plugins.foo;
+
+/*
+ * 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.
+ */
+
+public class Hello {
+
+    public static String sayHello(String who) throws Exception {
+        return "Hello " + who;
+    }
+
+}
\ No newline at end of file
diff --git a/src/it/MINVOKER-191/module-b/src/test/java/org/apache/maven/plugins/foo/HelloTest.java
b/src/it/MINVOKER-191/module-b/src/test/java/org/apache/maven/plugins/foo/HelloTest.java
new file mode 100644
index 0000000..f6c26db
--- /dev/null
+++ b/src/it/MINVOKER-191/module-b/src/test/java/org/apache/maven/plugins/foo/HelloTest.java
@@ -0,0 +1,32 @@
+package org.apache.maven.plugins.foo;
+
+/*
+ * 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.
+ */
+
+import org.junit.Test;
+
+public class HelloTest {
+
+    @Test
+    public void say_hello_test() throws Exception {
+        Hello.sayHello("foo");
+        Thread.sleep(2000);
+    }
+
+}
\ No newline at end of file
diff --git a/src/it/invocation-reactor-indirect/itests/pom.xml b/src/it/MINVOKER-191/plugin/pom.xml
similarity index 84%
copy from src/it/invocation-reactor-indirect/itests/pom.xml
copy to src/it/MINVOKER-191/plugin/pom.xml
index bcf529f..cf5b9fc 100644
--- a/src/it/invocation-reactor-indirect/itests/pom.xml
+++ b/src/it/MINVOKER-191/plugin/pom.xml
@@ -24,11 +24,19 @@ under the License.
   <modelVersion>4.0.0</modelVersion>
   <parent>
     <groupId>org.apache.maven.plugins.invoker</groupId>
-    <artifactId>MINVOKER-115-parent</artifactId>
+    <artifactId>MINVOKER-191-parent</artifactId>
     <version>1.0-SNAPSHOT</version>
   </parent>
-  <artifactId>MINVOKER-115-itests</artifactId>
-  <packaging>pom</packaging>
+  <artifactId>MINVOKER-191-plugin</artifactId>
+  <packaging>maven-plugin</packaging>
+
+  <dependencies>
+    <dependency>
+      <groupId>org.apache.maven</groupId>
+      <artifactId>maven-plugin-api</artifactId>
+      <version>2.0</version>
+    </dependency>
+  </dependencies>
 
   <build>
     <plugins>
diff --git a/src/it/invocation-reactor-indirect/itests/pom.xml b/src/it/MINVOKER-191/plugin/src/it/basic/pom.xml
similarity index 67%
copy from src/it/invocation-reactor-indirect/itests/pom.xml
copy to src/it/MINVOKER-191/plugin/src/it/basic/pom.xml
index bcf529f..6d3c05a 100644
--- a/src/it/invocation-reactor-indirect/itests/pom.xml
+++ b/src/it/MINVOKER-191/plugin/src/it/basic/pom.xml
@@ -22,29 +22,22 @@ under the License.
 <project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
   xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
   <modelVersion>4.0.0</modelVersion>
-  <parent>
-    <groupId>org.apache.maven.plugins.invoker</groupId>
-    <artifactId>MINVOKER-115-parent</artifactId>
-    <version>1.0-SNAPSHOT</version>
-  </parent>
-  <artifactId>MINVOKER-115-itests</artifactId>
+  <groupId>foo.it</groupId>
+  <artifactId>basic</artifactId>
+  <version>1.0-SNAPSHOT</version>
   <packaging>pom</packaging>
 
   <build>
     <plugins>
       <plugin>
-        <groupId>org.apache.maven.plugins</groupId>
-        <artifactId>maven-invoker-plugin</artifactId>
-        <configuration>
-          <cloneProjectsTo>${project.build.directory}/it</cloneProjectsTo>
-          <localRepositoryPath>${project.build.directory}/local-repo</localRepositoryPath>
-        </configuration>
+        <groupId>org.apache.maven.plugins.invoker</groupId>
+        <artifactId>MINVOKER-191-plugin</artifactId>
+        <version>1.0-SNAPSHOT</version>
         <executions>
           <execution>
-            <id>itests</id>
+            <id>touch</id>
             <goals>
-              <goal>install</goal>
-              <goal>run</goal>
+              <goal>touch</goal>
             </goals>
           </execution>
         </executions>
diff --git a/src/it/MINVOKER-191/plugin/src/main/java/org/apache/maven/it/plugins/dummy/MyMojo.java
b/src/it/MINVOKER-191/plugin/src/main/java/org/apache/maven/it/plugins/dummy/MyMojo.java
new file mode 100644
index 0000000..c225e4b
--- /dev/null
+++ b/src/it/MINVOKER-191/plugin/src/main/java/org/apache/maven/it/plugins/dummy/MyMojo.java
@@ -0,0 +1,78 @@
+package org.apache.maven.it.plugins.dummy;
+
+/*
+ * Copyright 2001-2005 The Apache Software Foundation.
+ *
+ * Licensed 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.
+ */
+
+import org.apache.maven.plugin.AbstractMojo;
+import org.apache.maven.plugin.MojoExecutionException;
+
+import java.io.File;
+import java.io.FileWriter;
+import java.io.IOException;
+
+/**
+ * @goal touch
+ * @phase process-sources
+ */
+public class MyMojo
+    extends AbstractMojo
+{
+    /**
+     * Location of the file.
+     * @parameter expression="${project.build.directory}"
+     * @required
+     */
+    private File outputDirectory;
+
+    public void execute()
+        throws MojoExecutionException
+    {
+        File f = outputDirectory;
+
+        if ( !f.exists() )
+        {
+            f.mkdirs();
+        }
+
+        File touch = new File( f, "touch.txt" );
+
+        FileWriter w = null;
+        try
+        {
+            w = new FileWriter( touch );
+
+            w.write( "touch.txt" );
+        }
+        catch ( IOException e )
+        {
+            throw new MojoExecutionException( "Error creating file " + touch, e );
+        }
+        finally
+        {
+            if ( w != null )
+            {
+                try
+                {
+                    w.close();
+                }
+                catch ( IOException e )
+                {
+                    // ignore
+                }
+            }
+        }
+    }
+}
diff --git a/src/it/MINVOKER-191/pom.xml b/src/it/MINVOKER-191/pom.xml
new file mode 100644
index 0000000..fc24aa5
--- /dev/null
+++ b/src/it/MINVOKER-191/pom.xml
@@ -0,0 +1,72 @@
+<?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.plugins.invoker</groupId>
+  <artifactId>MINVOKER-191-parent</artifactId>
+  <version>1.0-SNAPSHOT</version>
+  <packaging>pom</packaging>
+
+  <description>
+    Test of reported issue MINVOKER-191: install plugins try to install all reactors projects
+    even non dependendant projects which cause build using multi thread builds
+  </description>
+
+  <properties>
+    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+  </properties>
+
+  <modules>
+    <module>module-a</module>
+    <module>plugin</module>
+    <module>module-b</module>
+  </modules>
+
+  <build>
+    <pluginManagement>
+      <plugins>
+        <plugin>
+          <groupId>org.apache.maven.plugins</groupId>
+          <artifactId>maven-compiler-plugin</artifactId>
+          <version>2.5.1</version>
+        </plugin>
+        <plugin>
+          <groupId>org.apache.maven.plugins</groupId>
+          <artifactId>maven-plugin-plugin</artifactId>
+          <version>2.9</version>
+        </plugin>
+        <plugin>
+          <groupId>org.apache.maven.plugins</groupId>
+          <artifactId>maven-resources-plugin</artifactId>
+          <version>2.6</version>
+        </plugin>
+        <plugin>
+          <groupId>org.apache.maven.plugins</groupId>
+          <artifactId>maven-invoker-plugin</artifactId>
+          <version>@pom.version@</version>
+        </plugin>
+      </plugins>
+    </pluginManagement>
+  </build>
+</project>
diff --git a/src/it/invocation-reactor-indirect/itests/pom.xml b/src/it/invocation-reactor-indirect/itests/pom.xml
index bcf529f..cf5858b 100644
--- a/src/it/invocation-reactor-indirect/itests/pom.xml
+++ b/src/it/invocation-reactor-indirect/itests/pom.xml
@@ -30,6 +30,14 @@ under the License.
   <artifactId>MINVOKER-115-itests</artifactId>
   <packaging>pom</packaging>
 
+  <dependencies>
+    <dependency>
+      <groupId>org.apache.maven.plugins.invoker</groupId>
+      <artifactId>MINVOKER-115-plugin</artifactId>
+      <version>1.0-SNAPSHOT</version>
+    </dependency>
+  </dependencies>
+
   <build>
     <plugins>
       <plugin>
diff --git a/src/main/java/org/apache/maven/plugins/invoker/InstallMojo.java b/src/main/java/org/apache/maven/plugins/invoker/InstallMojo.java
index b0a0c21..c07c86a 100644
--- a/src/main/java/org/apache/maven/plugins/invoker/InstallMojo.java
+++ b/src/main/java/org/apache/maven/plugins/invoker/InstallMojo.java
@@ -28,6 +28,7 @@ import java.util.HashSet;
 import java.util.LinkedHashSet;
 import java.util.Map;
 
+import org.apache.commons.lang.StringUtils;
 import org.apache.maven.artifact.Artifact;
 import org.apache.maven.artifact.factory.ArtifactFactory;
 import org.apache.maven.artifact.repository.ArtifactRepository;
@@ -427,9 +428,8 @@ public class InstallMojo
 
             projects.put( projectId, reactorProject );
 
-            // only add projects of reactor build previous to this mvnProject
-            foundCurrent |= ( mvnProject.equals( reactorProject ) );
-            if ( !foundCurrent )
+            // only add projects used by the current project
+            if ( isInProjectReferences( project.getProjectReferences().values(), reactorProject
) )
             {
                 dependencyProjects.add( projectId );
             }
@@ -477,6 +477,22 @@ public class InstallMojo
         }
     }
 
+    protected boolean isInProjectReferences( Collection<MavenProject> references, MavenProject
project )
+    {
+        if ( references == null || references.isEmpty() )
+        {
+            return false;
+        }
+        for ( MavenProject mavenProject : references )
+        {
+            if ( StringUtils.equals( mavenProject.getId(), project.getId() ) )
+            {
+                return true;
+            }
+        }
+        return false;
+    }
+
     private void copyArtifact( Artifact artifact )
         throws MojoExecutionException
     {

-- 
To stop receiving notification emails like this one, please contact
olamy@apache.org.

Mime
View raw message