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 2012/11/21 22:13:56 UTC

svn commit: r1412302 - in /maven/plugins/trunk/maven-invoker-plugin/src: it/invocation-reactor-indirect/ it/invocation-reactor-indirect/itests/ it/invocation-reactor-indirect/itests/src/ it/invocation-reactor-indirect/itests/src/it/ it/invocation-react...

Author: rfscholte
Date: Wed Nov 21 21:13:53 2012
New Revision: 1412302

URL: http://svn.apache.org/viewvc?rev=1412302&view=rev
Log:
[MINVOKER-115] install goal doesn't install required plugins from the reactor build to the local repo 

Added:
    maven/plugins/trunk/maven-invoker-plugin/src/it/invocation-reactor-indirect/
    maven/plugins/trunk/maven-invoker-plugin/src/it/invocation-reactor-indirect/invoker.properties
    maven/plugins/trunk/maven-invoker-plugin/src/it/invocation-reactor-indirect/itests/
    maven/plugins/trunk/maven-invoker-plugin/src/it/invocation-reactor-indirect/itests/pom.xml
    maven/plugins/trunk/maven-invoker-plugin/src/it/invocation-reactor-indirect/itests/src/
    maven/plugins/trunk/maven-invoker-plugin/src/it/invocation-reactor-indirect/itests/src/it/
    maven/plugins/trunk/maven-invoker-plugin/src/it/invocation-reactor-indirect/itests/src/it/basic/
    maven/plugins/trunk/maven-invoker-plugin/src/it/invocation-reactor-indirect/itests/src/it/basic/pom.xml
    maven/plugins/trunk/maven-invoker-plugin/src/it/invocation-reactor-indirect/plugin/
    maven/plugins/trunk/maven-invoker-plugin/src/it/invocation-reactor-indirect/plugin/pom.xml
    maven/plugins/trunk/maven-invoker-plugin/src/it/invocation-reactor-indirect/plugin/src/
    maven/plugins/trunk/maven-invoker-plugin/src/it/invocation-reactor-indirect/plugin/src/main/
    maven/plugins/trunk/maven-invoker-plugin/src/it/invocation-reactor-indirect/plugin/src/main/java/
    maven/plugins/trunk/maven-invoker-plugin/src/it/invocation-reactor-indirect/plugin/src/main/java/org/
    maven/plugins/trunk/maven-invoker-plugin/src/it/invocation-reactor-indirect/plugin/src/main/java/org/apache/
    maven/plugins/trunk/maven-invoker-plugin/src/it/invocation-reactor-indirect/plugin/src/main/java/org/apache/maven/
    maven/plugins/trunk/maven-invoker-plugin/src/it/invocation-reactor-indirect/plugin/src/main/java/org/apache/maven/it/
    maven/plugins/trunk/maven-invoker-plugin/src/it/invocation-reactor-indirect/plugin/src/main/java/org/apache/maven/it/plugins/
    maven/plugins/trunk/maven-invoker-plugin/src/it/invocation-reactor-indirect/plugin/src/main/java/org/apache/maven/it/plugins/dummy/
    maven/plugins/trunk/maven-invoker-plugin/src/it/invocation-reactor-indirect/plugin/src/main/java/org/apache/maven/it/plugins/dummy/MyMojo.java
    maven/plugins/trunk/maven-invoker-plugin/src/it/invocation-reactor-indirect/pom.xml
Modified:
    maven/plugins/trunk/maven-invoker-plugin/src/main/java/org/apache/maven/plugin/invoker/InstallMojo.java

Added: maven/plugins/trunk/maven-invoker-plugin/src/it/invocation-reactor-indirect/invoker.properties
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-invoker-plugin/src/it/invocation-reactor-indirect/invoker.properties?rev=1412302&view=auto
==============================================================================
--- maven/plugins/trunk/maven-invoker-plugin/src/it/invocation-reactor-indirect/invoker.properties (added)
+++ maven/plugins/trunk/maven-invoker-plugin/src/it/invocation-reactor-indirect/invoker.properties Wed Nov 21 21:13:53 2012
@@ -0,0 +1 @@
+invoker.goals = clean install

Added: maven/plugins/trunk/maven-invoker-plugin/src/it/invocation-reactor-indirect/itests/pom.xml
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-invoker-plugin/src/it/invocation-reactor-indirect/itests/pom.xml?rev=1412302&view=auto
==============================================================================
--- maven/plugins/trunk/maven-invoker-plugin/src/it/invocation-reactor-indirect/itests/pom.xml (added)
+++ maven/plugins/trunk/maven-invoker-plugin/src/it/invocation-reactor-indirect/itests/pom.xml Wed Nov 21 21:13:53 2012
@@ -0,0 +1,34 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<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>
+  <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>
+        <executions>
+          <execution>
+            <id>itests</id>
+            <goals>
+              <goal>install</goal>
+              <goal>run</goal>
+            </goals>
+          </execution>
+        </executions>
+      </plugin>
+    </plugins>
+  </build>
+</project>

Added: maven/plugins/trunk/maven-invoker-plugin/src/it/invocation-reactor-indirect/itests/src/it/basic/pom.xml
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-invoker-plugin/src/it/invocation-reactor-indirect/itests/src/it/basic/pom.xml?rev=1412302&view=auto
==============================================================================
--- maven/plugins/trunk/maven-invoker-plugin/src/it/invocation-reactor-indirect/itests/src/it/basic/pom.xml (added)
+++ maven/plugins/trunk/maven-invoker-plugin/src/it/invocation-reactor-indirect/itests/src/it/basic/pom.xml Wed Nov 21 21:13:53 2012
@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<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>
+  <groupId>foo.it</groupId>
+  <artifactId>basic</artifactId>
+  <version>1.0-SNAPSHOT</version>
+  <packaging>pom</packaging>
+
+  <build>
+    <plugins>
+      <plugin>
+        <groupId>org.apache.maven.plugins.invoker</groupId>
+        <artifactId>MINVOKER-115-plugin</artifactId>
+        <version>1.0-SNAPSHOT</version>
+        <executions>
+          <execution>
+            <id>touch</id>
+            <goals>
+              <goal>touch</goal>
+            </goals>
+          </execution>
+        </executions>
+      </plugin>
+    </plugins>
+  </build>
+</project>

Added: maven/plugins/trunk/maven-invoker-plugin/src/it/invocation-reactor-indirect/plugin/pom.xml
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-invoker-plugin/src/it/invocation-reactor-indirect/plugin/pom.xml?rev=1412302&view=auto
==============================================================================
--- maven/plugins/trunk/maven-invoker-plugin/src/it/invocation-reactor-indirect/plugin/pom.xml (added)
+++ maven/plugins/trunk/maven-invoker-plugin/src/it/invocation-reactor-indirect/plugin/pom.xml Wed Nov 21 21:13:53 2012
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<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-plugin</artifactId>
+  <packaging>maven-plugin</packaging>
+
+  <dependencies>
+    <dependency>
+      <groupId>org.apache.maven</groupId>
+      <artifactId>maven-plugin-api</artifactId>
+      <version>2.0</version>
+    </dependency>
+  </dependencies>
+</project>

Added: maven/plugins/trunk/maven-invoker-plugin/src/it/invocation-reactor-indirect/plugin/src/main/java/org/apache/maven/it/plugins/dummy/MyMojo.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-invoker-plugin/src/it/invocation-reactor-indirect/plugin/src/main/java/org/apache/maven/it/plugins/dummy/MyMojo.java?rev=1412302&view=auto
==============================================================================
--- maven/plugins/trunk/maven-invoker-plugin/src/it/invocation-reactor-indirect/plugin/src/main/java/org/apache/maven/it/plugins/dummy/MyMojo.java (added)
+++ maven/plugins/trunk/maven-invoker-plugin/src/it/invocation-reactor-indirect/plugin/src/main/java/org/apache/maven/it/plugins/dummy/MyMojo.java Wed Nov 21 21:13:53 2012
@@ -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
+                }
+            }
+        }
+    }
+}

Added: maven/plugins/trunk/maven-invoker-plugin/src/it/invocation-reactor-indirect/pom.xml
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-invoker-plugin/src/it/invocation-reactor-indirect/pom.xml?rev=1412302&view=auto
==============================================================================
--- maven/plugins/trunk/maven-invoker-plugin/src/it/invocation-reactor-indirect/pom.xml (added)
+++ maven/plugins/trunk/maven-invoker-plugin/src/it/invocation-reactor-indirect/pom.xml Wed Nov 21 21:13:53 2012
@@ -0,0 +1,71 @@
+<?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-115-parent</artifactId>
+  <version>1.0-SNAPSHOT</version>
+  <packaging>pom</packaging>
+
+  <description>
+    Test of reported issue MINVOKER-115: install goal doesn't install plugins from the reactor
+    build to the local repo.
+  </description>
+
+  <properties>
+    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+  </properties>
+
+  <modules>
+    <module>plugin</module>
+    <module>itests</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>

Modified: maven/plugins/trunk/maven-invoker-plugin/src/main/java/org/apache/maven/plugin/invoker/InstallMojo.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-invoker-plugin/src/main/java/org/apache/maven/plugin/invoker/InstallMojo.java?rev=1412302&r1=1412301&r2=1412302&view=diff
==============================================================================
--- maven/plugins/trunk/maven-invoker-plugin/src/main/java/org/apache/maven/plugin/invoker/InstallMojo.java (original)
+++ maven/plugins/trunk/maven-invoker-plugin/src/main/java/org/apache/maven/plugin/invoker/InstallMojo.java Wed Nov 21 21:13:53 2012
@@ -444,6 +444,12 @@ public class InstallMojo
                                              ArtifactRepository testRepository )
         throws MojoExecutionException
     {
+        // keep track if we have passed mvnProject in reactorProjects 
+        boolean foundCurrent = false;
+
+        // ... into dependencies that were resolved from reactor projects ...
+        Collection<String> dependencyProjects = new LinkedHashSet<String>();
+        
         // index available reactor projects
         Map<String, MavenProject> projects = new HashMap<String, MavenProject>();
         for ( MavenProject reactorProject : reactorProjects )
@@ -452,14 +458,19 @@ public class InstallMojo
                 reactorProject.getGroupId() + ':' + reactorProject.getArtifactId() + ':' + reactorProject.getVersion();
 
             projects.put( projectId, reactorProject );
+            
+            // only add projects of reactor build previous to this mvnProject
+            if ( !( foundCurrent |= ( mvnProject.equals( reactorProject ) ) ) )
+            {
+                dependencyProjects.add( projectId );
+            }
         }
 
         // group transitive dependencies (even those that don't contribute to the class path like POMs) ...
         Collection<Artifact> artifacts = (Collection<Artifact>) mvnProject.getArtifacts();
-        // ... into dependencies that were resolved from reactor projects ...
-        Collection<String> dependencyProjects = new LinkedHashSet<String>();
         // ... and those that were resolved from the (local) repo
         Collection<Artifact> dependencyArtifacts = new LinkedHashSet<Artifact>();
+        
         for ( Artifact artifact : artifacts )
         {
             // workaround for MNG-2961 to ensure the base version does not contain a timestamp
@@ -467,11 +478,7 @@ public class InstallMojo
 
             String projectId = artifact.getGroupId() + ':' + artifact.getArtifactId() + ':' + artifact.getBaseVersion();
 
-            if ( projects.containsKey( projectId ) )
-            {
-                dependencyProjects.add( projectId );
-            }
-            else
+            if ( !projects.containsKey( projectId ) )
             {
                 dependencyArtifacts.add( artifact );
             }