Author: jdcasey
Date: Wed Feb 20 19:02:48 2013
New Revision: 1448351

URL: http://svn.apache.org/r1448351
Log:
[MDEP-401][MDEP-402] Adding excludeReactor parameter and 
getPluginArtifactsFilter() method, to make use of in/exclude parameters already 
in existence from the resolve-plugins mojo. Also adding ITs to verify this 
functionality.

Added:
    
maven/plugins/trunk/maven-dependency-plugin/src/it/resolve-plugins-exclude-reactor/
    
maven/plugins/trunk/maven-dependency-plugin/src/it/resolve-plugins-exclude-reactor/child-a/
    
maven/plugins/trunk/maven-dependency-plugin/src/it/resolve-plugins-exclude-reactor/child-a/pom.xml
   (with props)
    
maven/plugins/trunk/maven-dependency-plugin/src/it/resolve-plugins-exclude-reactor/child-a/src/
    
maven/plugins/trunk/maven-dependency-plugin/src/it/resolve-plugins-exclude-reactor/child-a/src/main/
    
maven/plugins/trunk/maven-dependency-plugin/src/it/resolve-plugins-exclude-reactor/child-a/src/main/resources/
    
maven/plugins/trunk/maven-dependency-plugin/src/it/resolve-plugins-exclude-reactor/child-a/src/main/resources/DoNotDelete.xml
   (with props)
    
maven/plugins/trunk/maven-dependency-plugin/src/it/resolve-plugins-exclude-reactor/child-b/
    
maven/plugins/trunk/maven-dependency-plugin/src/it/resolve-plugins-exclude-reactor/child-b/pom.xml
   (with props)
    
maven/plugins/trunk/maven-dependency-plugin/src/it/resolve-plugins-exclude-reactor/invoker.properties
   (with props)
    
maven/plugins/trunk/maven-dependency-plugin/src/it/resolve-plugins-exclude-reactor/pom.xml
   (with props)
    
maven/plugins/trunk/maven-dependency-plugin/src/it/resolve-plugins-exclude-reactor/verify.groovy
    
maven/plugins/trunk/maven-dependency-plugin/src/it/resolve-plugins-with-exclude/
    
maven/plugins/trunk/maven-dependency-plugin/src/it/resolve-plugins-with-exclude/invoker.properties
   (with props)
    
maven/plugins/trunk/maven-dependency-plugin/src/it/resolve-plugins-with-exclude/pom.xml
   (with props)
    
maven/plugins/trunk/maven-dependency-plugin/src/it/resolve-plugins-with-exclude/test.properties
   (with props)
    
maven/plugins/trunk/maven-dependency-plugin/src/it/resolve-plugins-with-exclude/verify.groovy
Modified:
    maven/plugins/trunk/maven-dependency-plugin/pom.xml
    
maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/AbstractResolveMojo.java
    
maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/resolvers/ResolvePluginsMojo.java

Modified: maven/plugins/trunk/maven-dependency-plugin/pom.xml
URL: 
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-dependency-plugin/pom.xml?rev=1448351&r1=1448350&r2=1448351&view=diff
==============================================================================
--- maven/plugins/trunk/maven-dependency-plugin/pom.xml (original)
+++ maven/plugins/trunk/maven-dependency-plugin/pom.xml Wed Feb 20 19:02:48 2013
@@ -141,7 +141,7 @@ under the License.
     <dependency>
       <groupId>org.codehaus.plexus</groupId>
       <artifactId>plexus-archiver</artifactId>
-      <version>2.3-SNAPSHOT</version>
+      <version>2.3</version>
     </dependency>
     <dependency>
       <groupId>org.codehaus.plexus</groupId>

Added: 
maven/plugins/trunk/maven-dependency-plugin/src/it/resolve-plugins-exclude-reactor/child-a/pom.xml
URL: 
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-dependency-plugin/src/it/resolve-plugins-exclude-reactor/child-a/pom.xml?rev=1448351&view=auto
==============================================================================
--- 
maven/plugins/trunk/maven-dependency-plugin/src/it/resolve-plugins-exclude-reactor/child-a/pom.xml
 (added)
+++ 
maven/plugins/trunk/maven-dependency-plugin/src/it/resolve-plugins-exclude-reactor/child-a/pom.xml
 Wed Feb 20 19:02:48 2013
@@ -0,0 +1,36 @@
+<?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.dependency</groupId>
+    <artifactId>test</artifactId>
+    <version>1.0-SNAPSHOT</version>
+  </parent>
+  <artifactId>child-a</artifactId>
+  <packaging>maven-plugin</packaging>
+
+  <name>Resolve-plugins skip reactor plugin</name>
+
+</project>

Propchange: 
maven/plugins/trunk/maven-dependency-plugin/src/it/resolve-plugins-exclude-reactor/child-a/pom.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Added: 
maven/plugins/trunk/maven-dependency-plugin/src/it/resolve-plugins-exclude-reactor/child-a/src/main/resources/DoNotDelete.xml
URL: 
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-dependency-plugin/src/it/resolve-plugins-exclude-reactor/child-a/src/main/resources/DoNotDelete.xml?rev=1448351&view=auto
==============================================================================
--- 
maven/plugins/trunk/maven-dependency-plugin/src/it/resolve-plugins-exclude-reactor/child-a/src/main/resources/DoNotDelete.xml
 (added)
+++ 
maven/plugins/trunk/maven-dependency-plugin/src/it/resolve-plugins-exclude-reactor/child-a/src/main/resources/DoNotDelete.xml
 Wed Feb 20 19:02:48 2013
@@ -0,0 +1,20 @@
+<?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.
+  -->
+<root/>

Propchange: 
maven/plugins/trunk/maven-dependency-plugin/src/it/resolve-plugins-exclude-reactor/child-a/src/main/resources/DoNotDelete.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Added: 
maven/plugins/trunk/maven-dependency-plugin/src/it/resolve-plugins-exclude-reactor/child-b/pom.xml
URL: 
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-dependency-plugin/src/it/resolve-plugins-exclude-reactor/child-b/pom.xml?rev=1448351&view=auto
==============================================================================
--- 
maven/plugins/trunk/maven-dependency-plugin/src/it/resolve-plugins-exclude-reactor/child-b/pom.xml
 (added)
+++ 
maven/plugins/trunk/maven-dependency-plugin/src/it/resolve-plugins-exclude-reactor/child-b/pom.xml
 Wed Feb 20 19:02:48 2013
@@ -0,0 +1,74 @@
+<?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.dependency</groupId>
+    <artifactId>test</artifactId>
+    <version>1.0-SNAPSHOT</version>
+  </parent>
+  <artifactId>child-b</artifactId>
+  <packaging>pom</packaging>
+
+  <name>Copy from reactor</name>
+  <description>
+    Test dependency:copy when searching the reactor
+  </description>
+
+  <properties>
+    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+  </properties>
+
+  <dependencies>
+    <dependency>
+      <groupId>org.apache.maven.its.dependency</groupId>
+      <artifactId>child-a</artifactId>
+      <version>1.0-SNAPSHOT</version>
+    </dependency>
+  </dependencies>
+
+  <build>
+    <plugins>
+      <plugin>
+        <artifactId>maven-dependency-plugin</artifactId>
+        <executions>
+          <execution>
+            <id>test</id>
+            <goals>
+              <goal>copy</goal>
+            </goals>
+            <configuration>
+              <artifactItems>
+                <artifactItem>
+                  <groupId>org.apache.maven.its.dependency</groupId>
+                  <artifactId>child-a</artifactId>
+                </artifactItem>
+              </artifactItems>
+            </configuration>
+          </execution>
+        </executions>
+      </plugin>
+    </plugins>
+  </build>
+</project>

Propchange: 
maven/plugins/trunk/maven-dependency-plugin/src/it/resolve-plugins-exclude-reactor/child-b/pom.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Added: 
maven/plugins/trunk/maven-dependency-plugin/src/it/resolve-plugins-exclude-reactor/invoker.properties
URL: 
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-dependency-plugin/src/it/resolve-plugins-exclude-reactor/invoker.properties?rev=1448351&view=auto
==============================================================================
--- 
maven/plugins/trunk/maven-dependency-plugin/src/it/resolve-plugins-exclude-reactor/invoker.properties
 (added)
+++ 
maven/plugins/trunk/maven-dependency-plugin/src/it/resolve-plugins-exclude-reactor/invoker.properties
 Wed Feb 20 19:02:48 2013
@@ -0,0 +1 @@
+invoker.goals = 
${project.groupId}:${project.artifactId}:${project.version}:resolve-plugins

Propchange: 
maven/plugins/trunk/maven-dependency-plugin/src/it/resolve-plugins-exclude-reactor/invoker.properties
------------------------------------------------------------------------------
    svn:eol-style = native

Added: 
maven/plugins/trunk/maven-dependency-plugin/src/it/resolve-plugins-exclude-reactor/pom.xml
URL: 
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-dependency-plugin/src/it/resolve-plugins-exclude-reactor/pom.xml?rev=1448351&view=auto
==============================================================================
--- 
maven/plugins/trunk/maven-dependency-plugin/src/it/resolve-plugins-exclude-reactor/pom.xml
 (added)
+++ 
maven/plugins/trunk/maven-dependency-plugin/src/it/resolve-plugins-exclude-reactor/pom.xml
 Wed Feb 20 19:02:48 2013
@@ -0,0 +1,62 @@
+<?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.dependency</groupId>
+  <artifactId>test</artifactId>
+  <version>1.0-SNAPSHOT</version>
+  <packaging>pom</packaging>
+
+  <modules>
+    <module>child-a</module>
+    <module>child-b</module>
+  </modules>
+
+  <name>resolve-plugins skip reactor plugins</name>
+  <description>
+    Test dependency:resolve-plugins to skip plugins in the reactor
+  </description>
+
+  <properties>
+    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+  </properties>
+
+  <build>
+    <plugins>
+      <plugin>
+        <artifactId>maven-dependency-plugin</artifactId>
+        <version>@project.version@</version>
+        <configuration>
+          <outputFile>target/resolved.txt</outputFile>
+          <excludeReactor>true</excludeReactor>
+        </configuration>
+      </plugin>
+      <plugin>
+        <groupId>org.apache.maven.its.dependency</groupId>
+        <artifactId>child-a</artifactId>
+        <version>1.0-SNAPSHOT</version>
+      </plugin>
+    </plugins>
+  </build>
+</project>

Propchange: 
maven/plugins/trunk/maven-dependency-plugin/src/it/resolve-plugins-exclude-reactor/pom.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Added: 
maven/plugins/trunk/maven-dependency-plugin/src/it/resolve-plugins-exclude-reactor/verify.groovy
URL: 
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-dependency-plugin/src/it/resolve-plugins-exclude-reactor/verify.groovy?rev=1448351&view=auto
==============================================================================
--- 
maven/plugins/trunk/maven-dependency-plugin/src/it/resolve-plugins-exclude-reactor/verify.groovy
 (added)
+++ 
maven/plugins/trunk/maven-dependency-plugin/src/it/resolve-plugins-exclude-reactor/verify.groovy
 Wed Feb 20 19:02:48 2013
@@ -0,0 +1,7 @@
+new File(basedir, "target/resolved.txt").eachLine { line -> 
+  if ( line =~ /child-a/ ){
+    throw new RuntimeException( "Reactor plugin 'child-a' should be excluded!" 
)
+  }
+}
+
+return true;

Added: 
maven/plugins/trunk/maven-dependency-plugin/src/it/resolve-plugins-with-exclude/invoker.properties
URL: 
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-dependency-plugin/src/it/resolve-plugins-with-exclude/invoker.properties?rev=1448351&view=auto
==============================================================================
--- 
maven/plugins/trunk/maven-dependency-plugin/src/it/resolve-plugins-with-exclude/invoker.properties
 (added)
+++ 
maven/plugins/trunk/maven-dependency-plugin/src/it/resolve-plugins-with-exclude/invoker.properties
 Wed Feb 20 19:02:48 2013
@@ -0,0 +1 @@
+invoker.goals = 
${project.groupId}:${project.artifactId}:${project.version}:resolve-plugins

Propchange: 
maven/plugins/trunk/maven-dependency-plugin/src/it/resolve-plugins-with-exclude/invoker.properties
------------------------------------------------------------------------------
    svn:eol-style = native

Added: 
maven/plugins/trunk/maven-dependency-plugin/src/it/resolve-plugins-with-exclude/pom.xml
URL: 
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-dependency-plugin/src/it/resolve-plugins-with-exclude/pom.xml?rev=1448351&view=auto
==============================================================================
--- 
maven/plugins/trunk/maven-dependency-plugin/src/it/resolve-plugins-with-exclude/pom.xml
 (added)
+++ 
maven/plugins/trunk/maven-dependency-plugin/src/it/resolve-plugins-with-exclude/pom.xml
 Wed Feb 20 19:02:48 2013
@@ -0,0 +1,54 @@
+<?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.dependency</groupId>
+  <artifactId>test</artifactId>
+  <version>1.0-SNAPSHOT</version>
+
+  <name>Test</name>
+  <description>
+    Test dependency:resolve-plugins with excluded artifactId
+  </description>
+
+  <properties>
+    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+  </properties>
+  
+  <build>
+    <pluginManagement>
+      <plugins>
+        <plugin>
+          <artifactId>maven-dependency-plugin</artifactId>
+          <version>@project.version@</version>
+          <configuration>
+            <outputFile>target/resolved.txt</outputFile>
+            
<excludeArtifactIds>maven-dependency-plugin,maven-surefire-plugin</excludeArtifactIds>
+          </configuration>
+        </plugin>
+      </plugins>
+    </pluginManagement>
+  </build>
+
+</project>

Propchange: 
maven/plugins/trunk/maven-dependency-plugin/src/it/resolve-plugins-with-exclude/pom.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Added: 
maven/plugins/trunk/maven-dependency-plugin/src/it/resolve-plugins-with-exclude/test.properties
URL: 
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-dependency-plugin/src/it/resolve-plugins-with-exclude/test.properties?rev=1448351&view=auto
==============================================================================
--- 
maven/plugins/trunk/maven-dependency-plugin/src/it/resolve-plugins-with-exclude/test.properties
 (added)
+++ 
maven/plugins/trunk/maven-dependency-plugin/src/it/resolve-plugins-with-exclude/test.properties
 Wed Feb 20 19:02:48 2013
@@ -0,0 +1 @@
+outputFile = target/resolved.txt

Propchange: 
maven/plugins/trunk/maven-dependency-plugin/src/it/resolve-plugins-with-exclude/test.properties
------------------------------------------------------------------------------
    svn:eol-style = native

Added: 
maven/plugins/trunk/maven-dependency-plugin/src/it/resolve-plugins-with-exclude/verify.groovy
URL: 
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-dependency-plugin/src/it/resolve-plugins-with-exclude/verify.groovy?rev=1448351&view=auto
==============================================================================
--- 
maven/plugins/trunk/maven-dependency-plugin/src/it/resolve-plugins-with-exclude/verify.groovy
 (added)
+++ 
maven/plugins/trunk/maven-dependency-plugin/src/it/resolve-plugins-with-exclude/verify.groovy
 Wed Feb 20 19:02:48 2013
@@ -0,0 +1,10 @@
+new File(basedir, "target/resolved.txt").eachLine { line -> 
+  if ( line =~ /maven-surefire-plugin/ ){
+    throw new RuntimeException( "Surefire plugin should be excluded!" )
+  }
+  else if ( line =~ /maven-dependency-plugin/ ){
+    throw new RuntimeException( "Dependency plugin should be excluded!" )
+  }
+}
+
+return true;

Modified: 
maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/AbstractResolveMojo.java
URL: 
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/AbstractResolveMojo.java?rev=1448351&r1=1448350&r2=1448351&view=diff
==============================================================================
--- 
maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/AbstractResolveMojo.java
 (original)
+++ 
maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/AbstractResolveMojo.java
 Wed Feb 20 19:02:48 2013
@@ -19,19 +19,26 @@ package org.apache.maven.plugin.dependen
  * under the License.
  */
 
+import java.io.File;
+import java.util.Set;
+
 import org.apache.maven.artifact.Artifact;
 import org.apache.maven.artifact.resolver.ArtifactNotFoundException;
 import org.apache.maven.artifact.resolver.ArtifactResolutionException;
 import org.apache.maven.artifact.resolver.filter.ScopeArtifactFilter;
+import org.apache.maven.plugin.dependency.utils.DependencyUtil;
 import org.apache.maven.plugins.annotations.Component;
 import org.apache.maven.plugins.annotations.Parameter;
 import org.apache.maven.project.MavenProject;
 import org.apache.maven.project.MavenProjectBuilder;
 import org.apache.maven.project.ProjectBuildingException;
 import org.apache.maven.project.artifact.InvalidDependencyVersionException;
-
-import java.io.File;
-import java.util.Set;
+import org.apache.maven.shared.artifact.filter.collection.ArtifactIdFilter;
+import org.apache.maven.shared.artifact.filter.collection.ClassifierFilter;
+import org.apache.maven.shared.artifact.filter.collection.FilterArtifacts;
+import org.apache.maven.shared.artifact.filter.collection.GroupIdFilter;
+import org.apache.maven.shared.artifact.filter.collection.ScopeFilter;
+import org.apache.maven.shared.artifact.filter.collection.TypeFilter;
 
 /**
  * @author <a href="mailto:bri...@apache.org";>Brian Fox</a>
@@ -75,13 +82,71 @@ public abstract class AbstractResolveMoj
     @Parameter( property = "appendOutput", defaultValue = "false" )
     protected boolean appendOutput;
 
-    protected Set<Artifact> resolveDependencyArtifacts( MavenProject 
theProject )
+    /**
+     * Don't resolve plugins that are in the current reactor. 
+     * Only works for plugins at the moment.
+     * 
+     * @since 2.7
+     */
+    @Parameter( property = "excludeReactor", defaultValue = "true" )
+    protected boolean excludeReactor;
+
+    protected FilterArtifacts getPluginArtifactsFilter()
+    {
+        if ( excludeReactor )
+        {
+            final StringBuilder exAids = new StringBuilder();
+            if ( this.excludeArtifactIds != null )
+            {
+                exAids.append( this.excludeArtifactIds );
+            }
+
+            for ( final MavenProject rp : reactorProjects )
+            {
+                if ( !"maven-plugin".equals( rp.getPackaging() ) )
+                {
+                    continue;
+                }
+
+                if ( exAids.length() > 0 )
+                {
+                    exAids.append( "," );
+                }
+
+                exAids.append( rp.getArtifactId() );
+            }
+
+            this.excludeArtifactIds = exAids.toString();
+        }
+
+        final FilterArtifacts filter = new FilterArtifacts();
+
+        filter.addFilter( new ScopeFilter( 
DependencyUtil.cleanToBeTokenizedString( this.includeScope ),
+                                           
DependencyUtil.cleanToBeTokenizedString( this.excludeScope ) ) );
+
+        filter.addFilter( new TypeFilter( 
DependencyUtil.cleanToBeTokenizedString( this.includeTypes ),
+                                          
DependencyUtil.cleanToBeTokenizedString( this.excludeTypes ) ) );
+
+        filter.addFilter( new ClassifierFilter( 
DependencyUtil.cleanToBeTokenizedString( this.includeClassifiers ),
+                                                
DependencyUtil.cleanToBeTokenizedString( this.excludeClassifiers ) ) );
+
+        filter.addFilter( new GroupIdFilter( 
DependencyUtil.cleanToBeTokenizedString( this.includeGroupIds ),
+                                             
DependencyUtil.cleanToBeTokenizedString( this.excludeGroupIds ) ) );
+
+        filter.addFilter( new ArtifactIdFilter( 
DependencyUtil.cleanToBeTokenizedString( this.includeArtifactIds ),
+                                                
DependencyUtil.cleanToBeTokenizedString( this.excludeArtifactIds ) ) );
+
+        return filter;
+    }
+
+    protected Set<Artifact> resolveDependencyArtifacts( final MavenProject 
theProject )
         throws ArtifactResolutionException, ArtifactNotFoundException, 
InvalidDependencyVersionException
     {
-        Set<Artifact> artifacts = theProject.createArtifacts( this.factory, 
Artifact.SCOPE_TEST,
-                                                              new 
ScopeArtifactFilter( Artifact.SCOPE_TEST ) );
+        final Set<Artifact> artifacts =
+            theProject.createArtifacts( this.factory, Artifact.SCOPE_TEST,
+                                        new ScopeArtifactFilter( 
Artifact.SCOPE_TEST ) );
 
-        for ( Artifact artifact : artifacts )
+        for ( final Artifact artifact : artifacts )
         {
             // resolve the new artifact
             this.resolver.resolve( artifact, this.remoteRepos, this.getLocal() 
);
@@ -100,15 +165,15 @@ public abstract class AbstractResolveMoj
      * @throws InvalidDependencyVersionException
      *
      */
-    protected Set<Artifact> resolveArtifactDependencies( Artifact artifact )
+    protected Set<Artifact> resolveArtifactDependencies( final Artifact 
artifact )
         throws ArtifactResolutionException, ArtifactNotFoundException, 
ProjectBuildingException,
         InvalidDependencyVersionException
     {
-        Artifact pomArtifact =
+        final Artifact pomArtifact =
             this.factory.createArtifact( artifact.getGroupId(), 
artifact.getArtifactId(), artifact.getVersion(), "",
                                          "pom" );
 
-        MavenProject pomProject =
+        final MavenProject pomProject =
             mavenProjectBuilder.buildFromRepository( pomArtifact, 
this.remoteRepos, this.getLocal() );
 
         return resolveDependencyArtifacts( pomProject );

Modified: 
maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/resolvers/ResolvePluginsMojo.java
URL: 
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/resolvers/ResolvePluginsMojo.java?rev=1448351&r1=1448350&r2=1448351&view=diff
==============================================================================
--- 
maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/resolvers/ResolvePluginsMojo.java
 (original)
+++ 
maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/resolvers/ResolvePluginsMojo.java
 Wed Feb 20 19:02:48 2013
@@ -19,6 +19,13 @@ package org.apache.maven.plugin.dependen
  * under the License.
  */
 
+import java.io.FileWriter;
+import java.io.IOException;
+import java.io.Writer;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
 import org.apache.maven.artifact.Artifact;
 import org.apache.maven.artifact.repository.ArtifactRepository;
 import org.apache.maven.artifact.resolver.ArtifactNotFoundException;
@@ -31,16 +38,11 @@ import org.apache.maven.plugins.annotati
 import org.apache.maven.plugins.annotations.Parameter;
 import org.apache.maven.project.ProjectBuildingException;
 import org.apache.maven.project.artifact.InvalidDependencyVersionException;
+import 
org.apache.maven.shared.artifact.filter.collection.ArtifactFilterException;
 import org.apache.maven.shared.artifact.filter.collection.ArtifactsFilter;
+import org.apache.maven.shared.artifact.filter.collection.FilterArtifacts;
 import org.codehaus.plexus.util.IOUtil;
 
-import java.io.FileWriter;
-import java.io.IOException;
-import java.io.Writer;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-
 /**
  * Goal that resolves all project plugins and reports and their dependencies.
  *
@@ -78,21 +80,23 @@ public class ResolvePluginsMojo
 
         try
         {
-            Set<Artifact> plugins = resolvePluginArtifacts();
+            final Set<Artifact> plugins = resolvePluginArtifacts();
 
             if ( this.outputFile != null )
             {
-                outputFile.getParentFile().mkdirs();
+                outputFile.getParentFile()
+                          .mkdirs();
 
                 outputWriter = new FileWriter( outputFile );
             }
 
-            for ( Artifact plugin : plugins )
+            for ( final Artifact plugin : plugins )
             {
                 String logStr = "Plugin Resolved: " + 
DependencyUtil.getFormattedFileName( plugin, false );
                 if ( !silent )
                 {
-                    this.getLog().info( logStr );
+                    this.getLog()
+                        .info( logStr );
                 }
 
                 if ( outputWriter != null )
@@ -103,14 +107,15 @@ public class ResolvePluginsMojo
 
                 if ( !excludeTransitive )
                 {
-                    for ( Artifact artifact : resolveArtifactDependencies( 
plugin ) )
+                    for ( final Artifact artifact : 
resolveArtifactDependencies( plugin ) )
                     {
                         logStr =
                             "    Plugin Dependency Resolved: " + 
DependencyUtil.getFormattedFileName( artifact, false );
 
                         if ( !silent )
                         {
-                            this.getLog().info( logStr );
+                            this.getLog()
+                                .info( logStr );
                         }
 
                         if ( outputWriter != null )
@@ -122,23 +127,27 @@ public class ResolvePluginsMojo
                 }
             }
         }
-        catch ( IOException e )
+        catch ( final IOException e )
         {
             throw new MojoExecutionException( "Nested:", e );
         }
-        catch ( ArtifactResolutionException e )
+        catch ( final ArtifactResolutionException e )
         {
             throw new MojoExecutionException( "Nested:", e );
         }
-        catch ( ArtifactNotFoundException e )
+        catch ( final ArtifactNotFoundException e )
         {
             throw new MojoExecutionException( "Nested:", e );
         }
-        catch ( ProjectBuildingException e )
+        catch ( final ProjectBuildingException e )
         {
             throw new MojoExecutionException( "Nested:", e );
         }
-        catch ( InvalidDependencyVersionException e )
+        catch ( final InvalidDependencyVersionException e )
+        {
+            throw new MojoExecutionException( "Nested:", e );
+        }
+        catch ( final ArtifactFilterException e )
         {
             throw new MojoExecutionException( "Nested:", e );
         }
@@ -155,25 +164,47 @@ public class ResolvePluginsMojo
      * @return set of resolved plugin artifacts.
      * @throws ArtifactResolutionException
      * @throws ArtifactNotFoundException
+     * @throws ArtifactFilterException 
      */
+    @SuppressWarnings( "unchecked" )
     protected Set<Artifact> resolvePluginArtifacts()
-        throws ArtifactResolutionException, ArtifactNotFoundException
+        throws ArtifactResolutionException, ArtifactNotFoundException, 
ArtifactFilterException
     {
-        @SuppressWarnings( "unchecked" ) Set<Artifact> plugins = 
project.getPluginArtifacts();
-        @SuppressWarnings( "unchecked" ) Set<Artifact> reports = 
project.getReportArtifacts();
+        final Set<Artifact> plugins = project.getPluginArtifacts();
+        final Set<Artifact> reports = project.getReportArtifacts();
 
         Set<Artifact> artifacts = new HashSet<Artifact>();
         artifacts.addAll( reports );
         artifacts.addAll( plugins );
 
-        for ( Artifact artifact : artifacts )
+        final FilterArtifacts filter = getPluginArtifactsFilter();
+        artifacts = filter.filter( artifacts );
+
+        //        final ArtifactFilter filter = getPluginFilter();
+        for ( final Artifact artifact : new HashSet<Artifact>( artifacts ) )
         {
+            //            if ( !filter.include( artifact ) )
+            //            {
+            //                final String logStr =
+            //                    String.format( "    Plugin SKIPPED: %s", 
DependencyUtil.getFormattedFileName( artifact, false ) );
+            //
+            //                if ( !silent )
+            //                {
+            //                    this.getLog()
+            //                        .info( logStr );
+            //                }
+            //
+            //                artifacts.remove( artifact );
+            //                continue;
+            //            }
+
             // resolve the new artifact
             this.resolver.resolve( artifact, this.remotePluginRepositories, 
this.getLocal() );
         }
         return artifacts;
     }
 
+    @Override
     protected ArtifactsFilter getMarkedArtifactFilter()
     {
         return null;


Reply via email to