Author: rfscholte
Date: Sat Jul  4 16:33:49 2015
New Revision: 1689175

URL: http://svn.apache.org/r1689175
Log:
Use DependencyCollector for list-repositories goal
Remove getLocal() from AbstractFromConfiguration, not used anymore

Added:
    
maven/plugins/trunk/maven-dependency-plugin/src/it/projects/list-repositories/
    
maven/plugins/trunk/maven-dependency-plugin/src/it/projects/list-repositories/invoker.properties
    
maven/plugins/trunk/maven-dependency-plugin/src/it/projects/list-repositories/pom.xml
Modified:
    maven/plugins/trunk/maven-dependency-plugin/src/it/mrm/settings.xml
    
maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/fromConfiguration/AbstractFromConfigurationMojo.java
    
maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/resolvers/ListRepositoriesMojo.java

Modified: maven/plugins/trunk/maven-dependency-plugin/src/it/mrm/settings.xml
URL: 
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-dependency-plugin/src/it/mrm/settings.xml?rev=1689175&r1=1689174&r2=1689175&view=diff
==============================================================================
--- maven/plugins/trunk/maven-dependency-plugin/src/it/mrm/settings.xml 
(original)
+++ maven/plugins/trunk/maven-dependency-plugin/src/it/mrm/settings.xml Sat Jul 
 4 16:33:49 2015
@@ -27,12 +27,10 @@ under the License.
       <mirrorOf>*</mirrorOf>
     </mirror>
   </mirrors>
+  
   <profiles>
     <profile>
       <id>it-repo</id>
-      <activation>
-        <activeByDefault>true</activeByDefault>
-      </activation>
       <repositories>
         <repository>
           <id>snapshots</id>
@@ -67,4 +65,8 @@ under the License.
       </pluginRepositories>
     </profile>
   </profiles>
+  
+  <activeProfiles>
+    <activeProfile>it-repo</activeProfile>
+  </activeProfiles>
 </settings>

Added: 
maven/plugins/trunk/maven-dependency-plugin/src/it/projects/list-repositories/invoker.properties
URL: 
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-dependency-plugin/src/it/projects/list-repositories/invoker.properties?rev=1689175&view=auto
==============================================================================
--- 
maven/plugins/trunk/maven-dependency-plugin/src/it/projects/list-repositories/invoker.properties
 (added)
+++ 
maven/plugins/trunk/maven-dependency-plugin/src/it/projects/list-repositories/invoker.properties
 Sat Jul  4 16:33:49 2015
@@ -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 = 
${project.groupId}:${project.artifactId}:${project.version}:list-repositories

Added: 
maven/plugins/trunk/maven-dependency-plugin/src/it/projects/list-repositories/pom.xml
URL: 
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-dependency-plugin/src/it/projects/list-repositories/pom.xml?rev=1689175&view=auto
==============================================================================
--- 
maven/plugins/trunk/maven-dependency-plugin/src/it/projects/list-repositories/pom.xml
 (added)
+++ 
maven/plugins/trunk/maven-dependency-plugin/src/it/projects/list-repositories/pom.xml
 Sat Jul  4 16:33:49 2015
@@ -0,0 +1,47 @@
+<?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:list-repositories
+  </description>
+
+  <properties>
+    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+  </properties>
+
+  <dependencies>
+    <dependency>
+      <groupId>org.apache.maven</groupId>
+      <artifactId>maven-project</artifactId>
+      <version>2.0.6</version>
+    </dependency>
+  </dependencies>
+
+</project>

Modified: 
maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/fromConfiguration/AbstractFromConfigurationMojo.java
URL: 
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/fromConfiguration/AbstractFromConfigurationMojo.java?rev=1689175&r1=1689174&r2=1689175&view=diff
==============================================================================
--- 
maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/fromConfiguration/AbstractFromConfigurationMojo.java
 (original)
+++ 
maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/fromConfiguration/AbstractFromConfigurationMojo.java
 Sat Jul  4 16:33:49 2015
@@ -411,51 +411,6 @@ public abstract class AbstractFromConfig
         return false;
     }
 
-    /*
-     * private Map createManagedVersionMap( ArtifactFactory artifactFactory, 
String projectId, DependencyManagement
-     * dependencyManagement ) throws MojoExecutionException { Map map; if ( 
dependencyManagement != null &&
-     * dependencyManagement.getDependencies() != null ) { map = new HashMap(); 
for ( Iterator i =
-     * dependencyManagement.getDependencies().iterator(); i.hasNext(); ) { 
Dependency d = (Dependency) i.next(); try {
-     * VersionRange versionRange = VersionRange.createFromVersionSpec( 
d.getVersion() ); Artifact artifact =
-     * artifactFactory.createDependencyArtifact( d.getGroupId(), 
d.getArtifactId(), versionRange, d.getType(), d
-     * .getClassifier(), d.getScope(), d .isOptional() ); map.put( 
d.getManagementKey(), artifact ); } catch (
-     * InvalidVersionSpecificationException e ) { throw new 
MojoExecutionException( "Unable to parse version", e ); } }
-     * } else { map = Collections.EMPTY_MAP; } return map; }
-     */
-
-    /**
-     * Override the base to
-     *
-     * @return Returns the local.
-     */
-    @Override
-    protected ArtifactRepository getLocal()
-    {
-        if ( this.overrideLocalRepository != null )
-        {
-            return this.overrideLocalRepository;
-        }
-
-        ArtifactRepository local = super.getLocal();
-
-        if ( this.localRepositoryDirectory != null )
-        {
-            // create a new local repo using existing layout, snapshots, and 
releases policy
-            String url = "file://" + 
this.localRepositoryDirectory.getAbsolutePath();
-            this.overrideLocalRepository =
-                artifactRepositoryManager.createArtifactRepository( 
local.getId(), url, local.getLayout(),
-                                                                    
local.getSnapshots(), local.getReleases() );
-
-            this.getLog().debug( "Execution local repository is at: " + 
this.overrideLocalRepository.getBasedir() );
-        }
-        else
-        {
-            this.overrideLocalRepository = local;
-        }
-
-        return this.overrideLocalRepository;
-    }
-
     /**
      * @return Returns the artifactItems.
      */

Modified: 
maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/resolvers/ListRepositoriesMojo.java
URL: 
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/resolvers/ListRepositoriesMojo.java?rev=1689175&r1=1689174&r2=1689175&view=diff
==============================================================================
--- 
maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/resolvers/ListRepositoriesMojo.java
 (original)
+++ 
maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/resolvers/ListRepositoriesMojo.java
 Sat Jul  4 16:33:49 2015
@@ -19,23 +19,15 @@ package org.apache.maven.plugin.dependen
  * under the License.
  */
 
-import org.apache.maven.artifact.Artifact;
 import org.apache.maven.artifact.repository.ArtifactRepository;
-import org.apache.maven.artifact.resolver.ArtifactCollector;
-import org.apache.maven.artifact.resolver.ArtifactResolutionException;
-import org.apache.maven.artifact.resolver.ArtifactResolutionResult;
-import org.apache.maven.artifact.resolver.ResolutionListener;
-import org.apache.maven.artifact.resolver.ResolutionNode;
 import org.apache.maven.plugin.MojoExecutionException;
 import org.apache.maven.plugin.dependency.AbstractDependencyMojo;
 import org.apache.maven.plugins.annotations.Component;
 import org.apache.maven.plugins.annotations.Mojo;
 import org.apache.maven.plugins.annotations.ResolutionScope;
-import org.apache.maven.shared.artifact.filter.ScopeArtifactFilter;
-
-import java.util.ArrayList;
-import java.util.HashSet;
-import java.util.Set;
+import org.apache.maven.shared.artifact.collect.CollectorResult;
+import org.apache.maven.shared.artifact.collect.DependencyCollector;
+import org.apache.maven.shared.artifact.collect.DependencyCollectorException;
 
 /**
  * Goal that resolves all project dependencies and then lists the repositories
@@ -50,10 +42,10 @@ public class ListRepositoriesMojo
     extends AbstractDependencyMojo
 {
     /**
-     * Artifact collector, needed to resolve dependencies.
+     * Dependency collector, needed to resolve dependencies.
      */
-    @Component( role = ArtifactCollector.class )
-    private ArtifactCollector artifactCollector;
+    @Component( role = DependencyCollector.class )
+    private DependencyCollector dependencyCollector;
 
     /**
      * Displays a list of the repositories used by this build.
@@ -66,44 +58,20 @@ public class ListRepositoriesMojo
     {
         try
         {
-            ArtifactResolutionResult result =
-                this.artifactCollector.collect( project.getArtifacts(), 
project.getArtifact(), this.getLocal(),
-                                                this.remoteRepos, 
this.artifactMetadataSource,
-                                                new ScopeArtifactFilter( 
Artifact.SCOPE_TEST ),
-                                                new 
ArrayList<ResolutionListener>() );
-            Set<ArtifactRepository> repos = new HashSet<ArtifactRepository>();
-            Set<ResolutionNode> nodes = result.getArtifactResolutionNodes();
-            for ( ResolutionNode node : nodes )
-            {
-                repos.addAll( node.getRemoteRepositories() );
-            }
+            CollectorResult collectResult =
+                dependencyCollector.collectDependencies( 
session.getProjectBuildingRequest(), project.getArtifact() );
 
             this.getLog().info( "Repositories Used by this build:" );
-            for ( ArtifactRepository repo : repos )
+            
+            for ( ArtifactRepository repo : 
collectResult.getRemoteRepositories() )
             {
                 this.getLog().info( repo.toString() );
             }
         }
-        catch ( ArtifactResolutionException e )
+        catch ( DependencyCollectorException e )
         {
             throw new MojoExecutionException( "Unable to resolve artifacts", e 
);
         }
     }
-    
-
-    /**
-     * @return Returns the artifactCollector.
-     */
-    public ArtifactCollector getArtifactCollector()
-    {
-        return this.artifactCollector;
-    }
 
-    /**
-     * @param theArtifactCollector The artifactCollector to set.
-     */
-    public void setArtifactCollector( ArtifactCollector theArtifactCollector )
-    {
-        this.artifactCollector = theArtifactCollector;
-    }
 }


Reply via email to