You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@maven.apache.org by GitBox <gi...@apache.org> on 2020/06/19 12:45:04 UTC

[GitHub] [maven-dependency-plugin] elharo commented on a change in pull request #51: [MDEP-425] List plugin repositories via maven-artifact-transfer.

elharo commented on a change in pull request #51:
URL: https://github.com/apache/maven-dependency-plugin/pull/51#discussion_r442814823



##########
File path: src/main/java/org/apache/maven/plugins/dependency/AbstractDependencyMojo.java
##########
@@ -345,11 +351,25 @@ private void silenceUnarchiver( UnArchiver unArchiver )
      *         repositories, used to resolve artifacts.
      */
     public ProjectBuildingRequest newResolveArtifactProjectBuildingRequest()
+    {
+        return newProjectBuildingRequest( remoteRepositories );
+    }
+
+    /**
+     * @return Returns a new ProjectBuildingRequest populated from the current session and the current project remote

Review comment:
       nit: Returns --> returns
   repositories, used --> Repositories. Used

##########
File path: src/main/java/org/apache/maven/plugins/dependency/ListClassesMojo.java
##########
@@ -0,0 +1,326 @@
+package org.apache.maven.plugins.dependency;
+
+/*
+ * 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 java.io.IOException;
+import java.util.ArrayList;
+import java.util.Enumeration;
+import java.util.List;
+import java.util.Map;
+import java.util.jar.JarEntry;
+import java.util.jar.JarFile;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import org.apache.maven.artifact.handler.ArtifactHandler;
+import org.apache.maven.artifact.handler.manager.ArtifactHandlerManager;
+import org.apache.maven.artifact.repository.ArtifactRepository;
+import org.apache.maven.artifact.repository.ArtifactRepositoryPolicy;
+import org.apache.maven.artifact.repository.MavenArtifactRepository;
+import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout;
+import org.apache.maven.execution.MavenSession;
+import org.apache.maven.plugin.AbstractMojo;
+import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.plugin.MojoFailureException;
+import org.apache.maven.plugins.annotations.Component;
+import org.apache.maven.plugins.annotations.Mojo;
+import org.apache.maven.plugins.annotations.Parameter;
+import org.apache.maven.project.DefaultProjectBuildingRequest;
+import org.apache.maven.project.ProjectBuildingRequest;
+import org.apache.maven.repository.RepositorySystem;
+import org.apache.maven.settings.Settings;
+import org.apache.maven.shared.transfer.artifact.ArtifactCoordinate;
+import org.apache.maven.shared.transfer.artifact.DefaultArtifactCoordinate;
+import org.apache.maven.shared.transfer.artifact.resolve.ArtifactResolver;
+import org.apache.maven.shared.transfer.artifact.resolve.ArtifactResolverException;
+import org.apache.maven.shared.transfer.artifact.resolve.ArtifactResult;
+import org.apache.maven.shared.transfer.dependencies.DefaultDependableCoordinate;
+import org.apache.maven.shared.transfer.dependencies.DependableCoordinate;
+import org.apache.maven.shared.transfer.dependencies.resolve.DependencyResolver;
+import org.apache.maven.shared.transfer.dependencies.resolve.DependencyResolverException;
+
+
+/**
+ * Retrieves and lists all classes contained in the specified artifact from the specified remote repositories.
+ */
+@Mojo( name = "list-classes", requiresProject = false, threadSafe = true )
+public class ListClassesMojo
+    extends AbstractMojo
+{
+    private static final Pattern ALT_REPO_SYNTAX_PATTERN = Pattern.compile( "(.+)::(.*)::(.+)" );
+
+    @Parameter( defaultValue = "${session}", required = true, readonly = true )
+    private MavenSession session;
+
+    @Component
+    private ArtifactResolver artifactResolver;
+
+    @Component
+    private DependencyResolver dependencyResolver;
+
+    @Component
+    private ArtifactHandlerManager artifactHandlerManager;
+
+    /**
+     * Map that contains the layouts.
+     */
+    @Component( role = ArtifactRepositoryLayout.class )
+    private Map<String, ArtifactRepositoryLayout> repositoryLayouts;
+
+    /**
+     * The repository system.
+     */
+    @Component
+    private RepositorySystem repositorySystem;
+
+    private DefaultDependableCoordinate coordinate = new DefaultDependableCoordinate();
+
+    /**
+     * The group ID of the artifact to download. Ignored if {@link #artifact} is used.
+     */
+    @Parameter( property = "groupId" )
+    private String groupId;
+
+    /**
+     * The artifact ID of the artifact to download. Ignored if {@link #artifact} is used.
+     */
+    @Parameter( property = "artifactId" )
+    private String artifactId;
+
+    /**
+     * The version of the artifact to download. Ignored if {@link #artifact} is used.
+     */
+    @Parameter( property = "version" )
+    private String version;
+
+    /**
+     * The classifier of the artifact to download. Ignored if {@link #artifact} is used.
+     *
+     * @since 2.3
+     */
+    @Parameter( property = "classifier" )
+    private String classifier;
+
+    /**
+     * The packaging of the artifact to download. Ignored if {@link #artifact} is used.
+     */
+    @Parameter( property = "packaging", defaultValue = "jar" )
+    private String packaging = "jar";
+
+    /**
+     * Repositories in the format id::[layout]::url or just URLs, separated by comma. That is,
+     * central::default::https://repo.maven.apache.org/maven2,myrepo::::https://repo.acme.com,https://repo.acme2.com
+     */
+    @Parameter( property = "remoteRepositories" )
+    private String remoteRepositories;
+
+    /**
+     * A string of the form groupId:artifactId:version[:packaging[:classifier]].
+     */
+    @Parameter( property = "artifact" )
+    private String artifact;
+
+    @Parameter( defaultValue = "${project.remoteArtifactRepositories}", readonly = true, required = true )
+    private List<ArtifactRepository> pomRemoteRepositories;
+
+    /**
+     * Download transitively, retrieving the specified artifact and all of its dependencies.
+     */
+    @Parameter( property = "transitive", defaultValue = "false" )
+    private boolean transitive = false;
+
+    /**
+     * Skip plugin execution completely.
+     */
+    @Parameter( property = "mdep.skip", defaultValue = "false" )
+    private boolean skip;
+
+    @Override
+    public void execute() throws MojoExecutionException, MojoFailureException
+    {
+        ProjectBuildingRequest buildingRequest = makeBuildingRequest();
+
+        try
+        {
+            if ( transitive )
+            {
+                Iterable<ArtifactResult> artifacts = dependencyResolver
+                        .resolveDependencies( buildingRequest, coordinate, null );
+
+                for ( ArtifactResult result : artifacts )
+                {
+                    printClassesFromArtifactResult( result );
+                }
+            }
+            else
+            {
+                ArtifactResult result = artifactResolver
+                        .resolveArtifact( buildingRequest, toArtifactCoordinate( coordinate ) );
+
+                printClassesFromArtifactResult( result );
+            }
+        }
+        catch ( ArtifactResolverException | DependencyResolverException | IOException e )
+        {
+            throw new MojoExecutionException( "Couldn't download artifact: " + e.getMessage(), e );
+        }
+    }
+
+    private void printClassesFromArtifactResult( ArtifactResult result )
+            throws IOException
+    {
+        // open jar file in try-with-resources statement to guarantee the file closes after use regardless of errors
+        try ( JarFile jarFile = new JarFile( result.getArtifact().getFile() ) )
+        {
+            Enumeration entries = jarFile.entries();
+
+            while ( entries.hasMoreElements() )
+            {
+                JarEntry entry = (JarEntry) entries.nextElement();
+                String entryName = entry.getName();
+
+                // filter out files that do not end in .class
+                if ( !entryName.endsWith( ".class" ) )
+                {
+                    continue;

Review comment:
       consider reversing the if and rewriting without continue

##########
File path: src/main/java/org/apache/maven/plugins/dependency/ListClassesMojo.java
##########
@@ -0,0 +1,326 @@
+package org.apache.maven.plugins.dependency;
+
+/*
+ * 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 java.io.IOException;
+import java.util.ArrayList;
+import java.util.Enumeration;
+import java.util.List;
+import java.util.Map;
+import java.util.jar.JarEntry;
+import java.util.jar.JarFile;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import org.apache.maven.artifact.handler.ArtifactHandler;
+import org.apache.maven.artifact.handler.manager.ArtifactHandlerManager;
+import org.apache.maven.artifact.repository.ArtifactRepository;
+import org.apache.maven.artifact.repository.ArtifactRepositoryPolicy;
+import org.apache.maven.artifact.repository.MavenArtifactRepository;
+import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout;
+import org.apache.maven.execution.MavenSession;
+import org.apache.maven.plugin.AbstractMojo;
+import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.plugin.MojoFailureException;
+import org.apache.maven.plugins.annotations.Component;
+import org.apache.maven.plugins.annotations.Mojo;
+import org.apache.maven.plugins.annotations.Parameter;
+import org.apache.maven.project.DefaultProjectBuildingRequest;
+import org.apache.maven.project.ProjectBuildingRequest;
+import org.apache.maven.repository.RepositorySystem;
+import org.apache.maven.settings.Settings;
+import org.apache.maven.shared.transfer.artifact.ArtifactCoordinate;
+import org.apache.maven.shared.transfer.artifact.DefaultArtifactCoordinate;
+import org.apache.maven.shared.transfer.artifact.resolve.ArtifactResolver;
+import org.apache.maven.shared.transfer.artifact.resolve.ArtifactResolverException;
+import org.apache.maven.shared.transfer.artifact.resolve.ArtifactResult;
+import org.apache.maven.shared.transfer.dependencies.DefaultDependableCoordinate;
+import org.apache.maven.shared.transfer.dependencies.DependableCoordinate;
+import org.apache.maven.shared.transfer.dependencies.resolve.DependencyResolver;
+import org.apache.maven.shared.transfer.dependencies.resolve.DependencyResolverException;
+
+
+/**
+ * Retrieves and lists all classes contained in the specified artifact from the specified remote repositories.
+ */
+@Mojo( name = "list-classes", requiresProject = false, threadSafe = true )
+public class ListClassesMojo
+    extends AbstractMojo
+{
+    private static final Pattern ALT_REPO_SYNTAX_PATTERN = Pattern.compile( "(.+)::(.*)::(.+)" );
+
+    @Parameter( defaultValue = "${session}", required = true, readonly = true )
+    private MavenSession session;
+
+    @Component
+    private ArtifactResolver artifactResolver;
+
+    @Component
+    private DependencyResolver dependencyResolver;
+
+    @Component
+    private ArtifactHandlerManager artifactHandlerManager;
+
+    /**
+     * Map that contains the layouts.
+     */
+    @Component( role = ArtifactRepositoryLayout.class )
+    private Map<String, ArtifactRepositoryLayout> repositoryLayouts;
+
+    /**
+     * The repository system.
+     */
+    @Component
+    private RepositorySystem repositorySystem;
+
+    private DefaultDependableCoordinate coordinate = new DefaultDependableCoordinate();
+
+    /**
+     * The group ID of the artifact to download. Ignored if {@link #artifact} is used.
+     */
+    @Parameter( property = "groupId" )
+    private String groupId;
+
+    /**
+     * The artifact ID of the artifact to download. Ignored if {@link #artifact} is used.
+     */
+    @Parameter( property = "artifactId" )
+    private String artifactId;
+
+    /**
+     * The version of the artifact to download. Ignored if {@link #artifact} is used.
+     */
+    @Parameter( property = "version" )
+    private String version;
+
+    /**
+     * The classifier of the artifact to download. Ignored if {@link #artifact} is used.
+     *
+     * @since 2.3
+     */
+    @Parameter( property = "classifier" )
+    private String classifier;
+
+    /**
+     * The packaging of the artifact to download. Ignored if {@link #artifact} is used.
+     */
+    @Parameter( property = "packaging", defaultValue = "jar" )
+    private String packaging = "jar";
+
+    /**
+     * Repositories in the format id::[layout]::url or just URLs, separated by comma. That is,
+     * central::default::https://repo.maven.apache.org/maven2,myrepo::::https://repo.acme.com,https://repo.acme2.com
+     */
+    @Parameter( property = "remoteRepositories" )
+    private String remoteRepositories;
+
+    /**
+     * A string of the form groupId:artifactId:version[:packaging[:classifier]].
+     */
+    @Parameter( property = "artifact" )
+    private String artifact;
+
+    @Parameter( defaultValue = "${project.remoteArtifactRepositories}", readonly = true, required = true )
+    private List<ArtifactRepository> pomRemoteRepositories;
+
+    /**
+     * Download transitively, retrieving the specified artifact and all of its dependencies.
+     */
+    @Parameter( property = "transitive", defaultValue = "false" )
+    private boolean transitive = false;
+
+    /**
+     * Skip plugin execution completely.
+     */
+    @Parameter( property = "mdep.skip", defaultValue = "false" )
+    private boolean skip;
+
+    @Override
+    public void execute() throws MojoExecutionException, MojoFailureException
+    {
+        ProjectBuildingRequest buildingRequest = makeBuildingRequest();
+
+        try
+        {
+            if ( transitive )
+            {
+                Iterable<ArtifactResult> artifacts = dependencyResolver
+                        .resolveDependencies( buildingRequest, coordinate, null );
+
+                for ( ArtifactResult result : artifacts )
+                {
+                    printClassesFromArtifactResult( result );
+                }
+            }
+            else
+            {
+                ArtifactResult result = artifactResolver
+                        .resolveArtifact( buildingRequest, toArtifactCoordinate( coordinate ) );
+
+                printClassesFromArtifactResult( result );
+            }
+        }
+        catch ( ArtifactResolverException | DependencyResolverException | IOException e )
+        {
+            throw new MojoExecutionException( "Couldn't download artifact: " + e.getMessage(), e );
+        }
+    }
+
+    private void printClassesFromArtifactResult( ArtifactResult result )

Review comment:
       delete "FromArtifactResult" as its redundant with the argument

##########
File path: src/main/java/org/apache/maven/plugins/dependency/ListClassesMojo.java
##########
@@ -0,0 +1,326 @@
+package org.apache.maven.plugins.dependency;
+
+/*
+ * 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 java.io.IOException;
+import java.util.ArrayList;
+import java.util.Enumeration;
+import java.util.List;
+import java.util.Map;
+import java.util.jar.JarEntry;
+import java.util.jar.JarFile;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import org.apache.maven.artifact.handler.ArtifactHandler;
+import org.apache.maven.artifact.handler.manager.ArtifactHandlerManager;
+import org.apache.maven.artifact.repository.ArtifactRepository;
+import org.apache.maven.artifact.repository.ArtifactRepositoryPolicy;
+import org.apache.maven.artifact.repository.MavenArtifactRepository;
+import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout;
+import org.apache.maven.execution.MavenSession;
+import org.apache.maven.plugin.AbstractMojo;
+import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.plugin.MojoFailureException;
+import org.apache.maven.plugins.annotations.Component;
+import org.apache.maven.plugins.annotations.Mojo;
+import org.apache.maven.plugins.annotations.Parameter;
+import org.apache.maven.project.DefaultProjectBuildingRequest;
+import org.apache.maven.project.ProjectBuildingRequest;
+import org.apache.maven.repository.RepositorySystem;
+import org.apache.maven.settings.Settings;
+import org.apache.maven.shared.transfer.artifact.ArtifactCoordinate;
+import org.apache.maven.shared.transfer.artifact.DefaultArtifactCoordinate;
+import org.apache.maven.shared.transfer.artifact.resolve.ArtifactResolver;
+import org.apache.maven.shared.transfer.artifact.resolve.ArtifactResolverException;
+import org.apache.maven.shared.transfer.artifact.resolve.ArtifactResult;
+import org.apache.maven.shared.transfer.dependencies.DefaultDependableCoordinate;
+import org.apache.maven.shared.transfer.dependencies.DependableCoordinate;
+import org.apache.maven.shared.transfer.dependencies.resolve.DependencyResolver;
+import org.apache.maven.shared.transfer.dependencies.resolve.DependencyResolverException;
+
+
+/**
+ * Retrieves and lists all classes contained in the specified artifact from the specified remote repositories.
+ */
+@Mojo( name = "list-classes", requiresProject = false, threadSafe = true )
+public class ListClassesMojo
+    extends AbstractMojo
+{
+    private static final Pattern ALT_REPO_SYNTAX_PATTERN = Pattern.compile( "(.+)::(.*)::(.+)" );
+
+    @Parameter( defaultValue = "${session}", required = true, readonly = true )
+    private MavenSession session;
+
+    @Component
+    private ArtifactResolver artifactResolver;
+
+    @Component
+    private DependencyResolver dependencyResolver;
+
+    @Component
+    private ArtifactHandlerManager artifactHandlerManager;
+
+    /**
+     * Map that contains the layouts.
+     */
+    @Component( role = ArtifactRepositoryLayout.class )
+    private Map<String, ArtifactRepositoryLayout> repositoryLayouts;
+
+    /**
+     * The repository system.
+     */
+    @Component
+    private RepositorySystem repositorySystem;
+
+    private DefaultDependableCoordinate coordinate = new DefaultDependableCoordinate();
+
+    /**
+     * The group ID of the artifact to download. Ignored if {@link #artifact} is used.
+     */
+    @Parameter( property = "groupId" )
+    private String groupId;
+
+    /**
+     * The artifact ID of the artifact to download. Ignored if {@link #artifact} is used.
+     */
+    @Parameter( property = "artifactId" )
+    private String artifactId;
+
+    /**
+     * The version of the artifact to download. Ignored if {@link #artifact} is used.
+     */
+    @Parameter( property = "version" )
+    private String version;
+
+    /**
+     * The classifier of the artifact to download. Ignored if {@link #artifact} is used.
+     *
+     * @since 2.3
+     */
+    @Parameter( property = "classifier" )
+    private String classifier;
+
+    /**
+     * The packaging of the artifact to download. Ignored if {@link #artifact} is used.
+     */
+    @Parameter( property = "packaging", defaultValue = "jar" )
+    private String packaging = "jar";
+
+    /**
+     * Repositories in the format id::[layout]::url or just URLs, separated by comma. That is,
+     * central::default::https://repo.maven.apache.org/maven2,myrepo::::https://repo.acme.com,https://repo.acme2.com
+     */
+    @Parameter( property = "remoteRepositories" )
+    private String remoteRepositories;
+
+    /**
+     * A string of the form groupId:artifactId:version[:packaging[:classifier]].
+     */
+    @Parameter( property = "artifact" )
+    private String artifact;
+
+    @Parameter( defaultValue = "${project.remoteArtifactRepositories}", readonly = true, required = true )
+    private List<ArtifactRepository> pomRemoteRepositories;
+
+    /**
+     * Download transitively, retrieving the specified artifact and all of its dependencies.
+     */
+    @Parameter( property = "transitive", defaultValue = "false" )
+    private boolean transitive = false;
+
+    /**
+     * Skip plugin execution completely.
+     */
+    @Parameter( property = "mdep.skip", defaultValue = "false" )
+    private boolean skip;
+
+    @Override
+    public void execute() throws MojoExecutionException, MojoFailureException
+    {
+        ProjectBuildingRequest buildingRequest = makeBuildingRequest();
+
+        try
+        {
+            if ( transitive )
+            {
+                Iterable<ArtifactResult> artifacts = dependencyResolver
+                        .resolveDependencies( buildingRequest, coordinate, null );
+
+                for ( ArtifactResult result : artifacts )
+                {
+                    printClassesFromArtifactResult( result );
+                }
+            }
+            else
+            {
+                ArtifactResult result = artifactResolver
+                        .resolveArtifact( buildingRequest, toArtifactCoordinate( coordinate ) );
+
+                printClassesFromArtifactResult( result );
+            }
+        }
+        catch ( ArtifactResolverException | DependencyResolverException | IOException e )
+        {
+            throw new MojoExecutionException( "Couldn't download artifact: " + e.getMessage(), e );
+        }
+    }
+
+    private void printClassesFromArtifactResult( ArtifactResult result )
+            throws IOException
+    {
+        // open jar file in try-with-resources statement to guarantee the file closes after use regardless of errors
+        try ( JarFile jarFile = new JarFile( result.getArtifact().getFile() ) )
+        {
+            Enumeration entries = jarFile.entries();
+
+            while ( entries.hasMoreElements() )
+            {
+                JarEntry entry = (JarEntry) entries.nextElement();
+                String entryName = entry.getName();
+
+                // filter out files that do not end in .class
+                if ( !entryName.endsWith( ".class" ) )
+                {
+                    continue;
+                }
+
+                // remove .class from the end and change format to use periods instead of forward slashes
+                String className = entryName.substring( 0, entryName.length() - 6 ).replace( '/', '.' );
+                getLog().info( className );
+            }
+        }
+    }
+
+    private ProjectBuildingRequest makeBuildingRequest()
+            throws MojoExecutionException, MojoFailureException
+    {
+        if ( artifact == null )
+        {
+            throw new MojoFailureException( "You must specify an artifact, "
+                    + "e.g. -Dartifact=org.apache.maven.plugins:maven-downloader-plugin:1.0" );
+        }
+        if ( artifact != null )
+        {
+            String[] tokens = artifact.split( ":" );
+            if ( tokens.length < 3 || tokens.length > 5 )
+            {
+                throw new MojoFailureException( "Invalid artifact, you must specify "
+                        + "groupId:artifactId:version[:packaging[:classifier]] " + artifact );
+            }
+            coordinate.setGroupId( tokens[0] );
+            coordinate.setArtifactId( tokens[1] );
+            coordinate.setVersion( tokens[2] );
+            if ( tokens.length >= 4 )
+            {
+                coordinate.setType( tokens[3] );
+            }
+            if ( tokens.length == 5 )
+            {
+                coordinate.setClassifier( tokens[4] );
+            }
+        }
+
+        ArtifactRepositoryPolicy always =
+                new ArtifactRepositoryPolicy( true, ArtifactRepositoryPolicy.UPDATE_POLICY_ALWAYS,
+                        ArtifactRepositoryPolicy.CHECKSUM_POLICY_WARN );
+
+        List<ArtifactRepository> repoList = new ArrayList<>();
+
+        if ( pomRemoteRepositories != null )
+        {
+            repoList.addAll( pomRemoteRepositories );
+        }
+
+        if ( remoteRepositories != null )
+        {
+            // Use the same format as in the deploy plugin id::layout::url
+            String[] repos = remoteRepositories.split( "," );
+            for ( String repo : repos )
+            {
+                repoList.add( parseRepository( repo, always ) );
+            }
+        }
+
+        ProjectBuildingRequest buildingRequest =
+                new DefaultProjectBuildingRequest( session.getProjectBuildingRequest() );
+
+        Settings settings = session.getSettings();
+        repositorySystem.injectMirror( repoList, settings.getMirrors() );
+        repositorySystem.injectProxy( repoList, settings.getProxies() );
+        repositorySystem.injectAuthentication( repoList, settings.getServers() );
+
+        buildingRequest.setRemoteRepositories( repoList );
+
+        return buildingRequest;
+    }
+
+    protected ArtifactCoordinate toArtifactCoordinate( DependableCoordinate dependableCoordinate )

Review comment:
       why protected?

##########
File path: src/main/java/org/apache/maven/plugins/dependency/resolvers/ListPluginRepositoriesMojo.java
##########
@@ -0,0 +1,323 @@
+package org.apache.maven.plugins.dependency.resolvers;
+
+/*
+ * 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 java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import org.apache.maven.artifact.Artifact;
+import org.apache.maven.artifact.ArtifactUtils;
+import org.apache.maven.artifact.repository.ArtifactRepository;
+import org.apache.maven.model.Model;
+import org.apache.maven.model.Repository;
+import org.apache.maven.model.building.ModelBuildingRequest;
+import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.plugins.annotations.Component;
+import org.apache.maven.plugins.annotations.Mojo;
+import org.apache.maven.plugins.annotations.Parameter;
+import org.apache.maven.plugins.annotations.ResolutionScope;
+import org.apache.maven.plugins.dependency.AbstractDependencyMojo;
+import org.apache.maven.project.DefaultProjectBuildingRequest;
+import org.apache.maven.project.MavenProject;
+import org.apache.maven.project.ProjectBuilder;
+import org.apache.maven.project.ProjectBuildingRequest;
+import org.apache.maven.settings.Mirror;
+import org.apache.maven.settings.Settings;
+import org.apache.maven.shared.transfer.artifact.ArtifactCoordinate;
+import org.apache.maven.shared.transfer.artifact.DefaultArtifactCoordinate;
+import org.apache.maven.shared.transfer.artifact.resolve.ArtifactResolver;
+
+/**
+ * Goal that resolves all project plugin dependencies and then lists the repositories used by the build
+ *
+ * @author <a href="mailto:pim.moerenhout@gmail.com">Pim Moerenhout</a>
+ * @since 3.1.2
+ */
+@Mojo( name = "list-plugin-repositories", requiresDependencyResolution = ResolutionScope.TEST, threadSafe = true )
+public class ListPluginRepositoriesMojo
+    extends AbstractDependencyMojo
+{
+    /**
+     * Maven Project Builder component.
+    */
+    @Component
+    private ProjectBuilder projectBuilder;
+
+    /**
+     * Component used to resolve artifacts and download their files from remote repositories.
+     */
+    @Component
+    private ArtifactResolver artifactResolver;
+
+    /**
+     * The system settings for Maven. This is the instance resulting from
+     * merging global and user-level settings files.
+     */
+    @Parameter( defaultValue = "${settings}", readonly = true, required = true )
+    private Settings settings;
+
+    /**
+     * Plugin repositories used for the project.
+     */
+    @Parameter( defaultValue = "${project.pluginArtifactRepositories}", readonly = true, required = true )
+    private List<ArtifactRepository> pluginRepositories;
+
+    /**
+     * Sets whether the plugin runs in verbose mode. As of plugin version 2.3, the default value is derived from Maven's
+     * global debug flag (compare command line switch <code>-X</code>).
+     *
+     * @since 3.1.2
+     */
+    @Parameter( property = "verbose" )
+    private boolean verbose;
+
+    /**
+     * Displays a list of the plugin repositories used by this build.
+     *
+     * @throws MojoExecutionException with a message if an error occurs.
+     */
+    @Override
+    protected void doExecute()
+        throws MojoExecutionException
+    {
+        final List<ArtifactRepository> repositories = pluginRepositories;
+        final Set<Artifact> artifacts = getProject().getPluginArtifacts();
+
+        this.getLog().info( "Plugin repositories used by this build:" );
+        for ( ArtifactRepository repo : repositories )
+        {
+            if ( isVerbose() )
+            {
+                Set<String> locations = new HashSet<String>();
+                for ( Mirror mirror : settings.getMirrors() )
+                {
+                    if ( mirror.getId().equals( repo.getId() )
+                        && ( mirror.getUrl().equals( repo.getUrl() ) ) )
+                    {
+                        locations.add( "Maven settings (user/global)" );
+                    }
+                }
+
+                Artifact projectArtifact = getProject().getArtifact();
+                MavenProject project = getMavenProject( ArtifactUtils.key( projectArtifact ) );
+                traversePom( repo, projectArtifact, project, locations );
+
+                for ( Artifact artifact : artifacts )
+                {
+                    MavenProject artifactProject = getMavenProject( ArtifactUtils.key( artifact ) );
+                    traversePom( repo, artifact, artifactProject, locations );
+                }
+                writeRepository( repo, locations );
+            }
+            else
+            {
+                this.getLog().info( repo.toString() );
+            }
+        }
+    }
+
+    private void writeRepository( ArtifactRepository artifactRepository, Set<String> locations )
+    {
+        StringBuilder sb = new StringBuilder( 256 );
+        sb.append( artifactRepository.toString() );
+        for ( String location : locations )
+        {
+            sb.append( " location: " ).append( location ).append( System.lineSeparator() );
+        }
+        this.getLog().info( sb.toString() );
+    }
+
+    /**
+     * Parses the given String into GAV artifact coordinate information, adding the given type.
+     *
+     * @param artifactString should respect the format <code>groupId:artifactId[:version]</code>
+     * @param type The extension for the artifact, must not be <code>null</code>.
+     * @return the <code>Artifact</code> object for the <code>artifactString</code> parameter.
+     * @throws MojoExecutionException if the <code>artifactString</code> doesn't respect the format.
+     */
+    private ArtifactCoordinate getArtifactCoordinate( String artifactString, String type )
+        throws MojoExecutionException
+    {
+        if ( org.codehaus.plexus.util.StringUtils.isEmpty( artifactString ) )
+        {
+            throw new IllegalArgumentException( "artifact parameter could not be empty" );
+        }
+
+        String groupId; // required
+        String artifactId; // required
+        String version; // optional
+
+        String[] artifactParts = artifactString.split( ":" );
+        switch ( artifactParts.length )
+        {
+            case 2:
+                groupId = artifactParts[0];
+                artifactId = artifactParts[1];
+                version = Artifact.LATEST_VERSION;
+                break;
+            case 3:
+                groupId = artifactParts[0];
+                artifactId = artifactParts[1];
+                version = artifactParts[2];
+                break;
+            default:
+                throw new MojoExecutionException( "The artifact parameter '" + artifactString
+                    + "' should be conform to: " + "'groupId:artifactId[:version]'." );
+        }
+        return getArtifactCoordinate( groupId, artifactId, version, type );
+    }
+
+    private ArtifactCoordinate getArtifactCoordinate( String groupId, String artifactId, String version, String type )
+    {
+        DefaultArtifactCoordinate coordinate = new DefaultArtifactCoordinate();
+        coordinate.setGroupId( groupId );
+        coordinate.setArtifactId( artifactId );
+        coordinate.setVersion( version );
+        coordinate.setExtension( type );
+        return coordinate;
+    }
+
+    /**
+     * Retrieves the Maven Project associated with the given artifact String, in the form of
+     * <code>groupId:artifactId[:version]</code>. This resolves the POM artifact at those coordinates and then builds
+     * the Maven project from it.
+     *
+     * @param artifactString Coordinates of the Maven project to get.
+     * @return New Maven project.
+     * @throws MojoExecutionException If there was an error while getting the Maven project.
+     */
+    private MavenProject getMavenProject( String artifactString )
+        throws MojoExecutionException
+    {
+        ArtifactCoordinate coordinate = getArtifactCoordinate( artifactString, "pom" );
+        try
+        {
+            ProjectBuildingRequest pbr = new DefaultProjectBuildingRequest( session.getProjectBuildingRequest() );
+            pbr.setRemoteRepositories( pluginRepositories );
+            pbr.setProject( null );
+            pbr.setValidationLevel( ModelBuildingRequest.VALIDATION_LEVEL_MINIMAL );
+            pbr.setResolveDependencies( false );
+            Artifact artifact = artifactResolver.resolveArtifact( pbr, coordinate ).getArtifact();
+            return projectBuilder.build( artifact.getFile(), pbr ).getProject();
+        }
+        catch ( Exception e )

Review comment:
       avoid catching Exception. Can this be more specific?

##########
File path: src/main/java/org/apache/maven/plugins/dependency/ListClassesMojo.java
##########
@@ -0,0 +1,326 @@
+package org.apache.maven.plugins.dependency;
+
+/*
+ * 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 java.io.IOException;
+import java.util.ArrayList;
+import java.util.Enumeration;
+import java.util.List;
+import java.util.Map;
+import java.util.jar.JarEntry;
+import java.util.jar.JarFile;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import org.apache.maven.artifact.handler.ArtifactHandler;
+import org.apache.maven.artifact.handler.manager.ArtifactHandlerManager;
+import org.apache.maven.artifact.repository.ArtifactRepository;
+import org.apache.maven.artifact.repository.ArtifactRepositoryPolicy;
+import org.apache.maven.artifact.repository.MavenArtifactRepository;
+import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout;
+import org.apache.maven.execution.MavenSession;
+import org.apache.maven.plugin.AbstractMojo;
+import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.plugin.MojoFailureException;
+import org.apache.maven.plugins.annotations.Component;
+import org.apache.maven.plugins.annotations.Mojo;
+import org.apache.maven.plugins.annotations.Parameter;
+import org.apache.maven.project.DefaultProjectBuildingRequest;
+import org.apache.maven.project.ProjectBuildingRequest;
+import org.apache.maven.repository.RepositorySystem;
+import org.apache.maven.settings.Settings;
+import org.apache.maven.shared.transfer.artifact.ArtifactCoordinate;
+import org.apache.maven.shared.transfer.artifact.DefaultArtifactCoordinate;
+import org.apache.maven.shared.transfer.artifact.resolve.ArtifactResolver;
+import org.apache.maven.shared.transfer.artifact.resolve.ArtifactResolverException;
+import org.apache.maven.shared.transfer.artifact.resolve.ArtifactResult;
+import org.apache.maven.shared.transfer.dependencies.DefaultDependableCoordinate;
+import org.apache.maven.shared.transfer.dependencies.DependableCoordinate;
+import org.apache.maven.shared.transfer.dependencies.resolve.DependencyResolver;
+import org.apache.maven.shared.transfer.dependencies.resolve.DependencyResolverException;
+
+
+/**
+ * Retrieves and lists all classes contained in the specified artifact from the specified remote repositories.
+ */
+@Mojo( name = "list-classes", requiresProject = false, threadSafe = true )
+public class ListClassesMojo
+    extends AbstractMojo
+{
+    private static final Pattern ALT_REPO_SYNTAX_PATTERN = Pattern.compile( "(.+)::(.*)::(.+)" );
+
+    @Parameter( defaultValue = "${session}", required = true, readonly = true )
+    private MavenSession session;
+
+    @Component
+    private ArtifactResolver artifactResolver;
+
+    @Component
+    private DependencyResolver dependencyResolver;
+
+    @Component
+    private ArtifactHandlerManager artifactHandlerManager;
+
+    /**
+     * Map that contains the layouts.
+     */
+    @Component( role = ArtifactRepositoryLayout.class )
+    private Map<String, ArtifactRepositoryLayout> repositoryLayouts;
+
+    /**
+     * The repository system.
+     */
+    @Component
+    private RepositorySystem repositorySystem;
+
+    private DefaultDependableCoordinate coordinate = new DefaultDependableCoordinate();
+
+    /**
+     * The group ID of the artifact to download. Ignored if {@link #artifact} is used.
+     */
+    @Parameter( property = "groupId" )
+    private String groupId;
+
+    /**
+     * The artifact ID of the artifact to download. Ignored if {@link #artifact} is used.
+     */
+    @Parameter( property = "artifactId" )
+    private String artifactId;
+
+    /**
+     * The version of the artifact to download. Ignored if {@link #artifact} is used.
+     */
+    @Parameter( property = "version" )
+    private String version;
+
+    /**
+     * The classifier of the artifact to download. Ignored if {@link #artifact} is used.
+     *
+     * @since 2.3
+     */
+    @Parameter( property = "classifier" )
+    private String classifier;
+
+    /**
+     * The packaging of the artifact to download. Ignored if {@link #artifact} is used.
+     */
+    @Parameter( property = "packaging", defaultValue = "jar" )
+    private String packaging = "jar";
+
+    /**
+     * Repositories in the format id::[layout]::url or just URLs, separated by comma. That is,
+     * central::default::https://repo.maven.apache.org/maven2,myrepo::::https://repo.acme.com,https://repo.acme2.com
+     */
+    @Parameter( property = "remoteRepositories" )
+    private String remoteRepositories;
+
+    /**
+     * A string of the form groupId:artifactId:version[:packaging[:classifier]].
+     */
+    @Parameter( property = "artifact" )
+    private String artifact;
+
+    @Parameter( defaultValue = "${project.remoteArtifactRepositories}", readonly = true, required = true )
+    private List<ArtifactRepository> pomRemoteRepositories;
+
+    /**
+     * Download transitively, retrieving the specified artifact and all of its dependencies.
+     */
+    @Parameter( property = "transitive", defaultValue = "false" )
+    private boolean transitive = false;
+
+    /**
+     * Skip plugin execution completely.
+     */
+    @Parameter( property = "mdep.skip", defaultValue = "false" )
+    private boolean skip;
+
+    @Override
+    public void execute() throws MojoExecutionException, MojoFailureException
+    {
+        ProjectBuildingRequest buildingRequest = makeBuildingRequest();
+
+        try
+        {
+            if ( transitive )
+            {
+                Iterable<ArtifactResult> artifacts = dependencyResolver
+                        .resolveDependencies( buildingRequest, coordinate, null );
+
+                for ( ArtifactResult result : artifacts )
+                {
+                    printClassesFromArtifactResult( result );
+                }
+            }
+            else
+            {
+                ArtifactResult result = artifactResolver
+                        .resolveArtifact( buildingRequest, toArtifactCoordinate( coordinate ) );
+
+                printClassesFromArtifactResult( result );
+            }
+        }
+        catch ( ArtifactResolverException | DependencyResolverException | IOException e )
+        {
+            throw new MojoExecutionException( "Couldn't download artifact: " + e.getMessage(), e );
+        }
+    }
+
+    private void printClassesFromArtifactResult( ArtifactResult result )
+            throws IOException
+    {
+        // open jar file in try-with-resources statement to guarantee the file closes after use regardless of errors
+        try ( JarFile jarFile = new JarFile( result.getArtifact().getFile() ) )
+        {
+            Enumeration entries = jarFile.entries();
+
+            while ( entries.hasMoreElements() )
+            {
+                JarEntry entry = (JarEntry) entries.nextElement();
+                String entryName = entry.getName();
+
+                // filter out files that do not end in .class
+                if ( !entryName.endsWith( ".class" ) )
+                {
+                    continue;
+                }
+
+                // remove .class from the end and change format to use periods instead of forward slashes
+                String className = entryName.substring( 0, entryName.length() - 6 ).replace( '/', '.' );
+                getLog().info( className );
+            }
+        }
+    }
+
+    private ProjectBuildingRequest makeBuildingRequest()
+            throws MojoExecutionException, MojoFailureException
+    {
+        if ( artifact == null )
+        {
+            throw new MojoFailureException( "You must specify an artifact, "
+                    + "e.g. -Dartifact=org.apache.maven.plugins:maven-downloader-plugin:1.0" );
+        }
+        if ( artifact != null )
+        {
+            String[] tokens = artifact.split( ":" );
+            if ( tokens.length < 3 || tokens.length > 5 )
+            {
+                throw new MojoFailureException( "Invalid artifact, you must specify "
+                        + "groupId:artifactId:version[:packaging[:classifier]] " + artifact );
+            }
+            coordinate.setGroupId( tokens[0] );
+            coordinate.setArtifactId( tokens[1] );
+            coordinate.setVersion( tokens[2] );
+            if ( tokens.length >= 4 )
+            {
+                coordinate.setType( tokens[3] );
+            }
+            if ( tokens.length == 5 )

Review comment:
       >= for safety

##########
File path: src/main/java/org/apache/maven/plugins/dependency/resolvers/ListPluginRepositoriesMojo.java
##########
@@ -0,0 +1,323 @@
+package org.apache.maven.plugins.dependency.resolvers;
+
+/*
+ * 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 java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import org.apache.maven.artifact.Artifact;
+import org.apache.maven.artifact.ArtifactUtils;
+import org.apache.maven.artifact.repository.ArtifactRepository;
+import org.apache.maven.model.Model;
+import org.apache.maven.model.Repository;
+import org.apache.maven.model.building.ModelBuildingRequest;
+import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.plugins.annotations.Component;
+import org.apache.maven.plugins.annotations.Mojo;
+import org.apache.maven.plugins.annotations.Parameter;
+import org.apache.maven.plugins.annotations.ResolutionScope;
+import org.apache.maven.plugins.dependency.AbstractDependencyMojo;
+import org.apache.maven.project.DefaultProjectBuildingRequest;
+import org.apache.maven.project.MavenProject;
+import org.apache.maven.project.ProjectBuilder;
+import org.apache.maven.project.ProjectBuildingRequest;
+import org.apache.maven.settings.Mirror;
+import org.apache.maven.settings.Settings;
+import org.apache.maven.shared.transfer.artifact.ArtifactCoordinate;
+import org.apache.maven.shared.transfer.artifact.DefaultArtifactCoordinate;
+import org.apache.maven.shared.transfer.artifact.resolve.ArtifactResolver;
+
+/**
+ * Goal that resolves all project plugin dependencies and then lists the repositories used by the build
+ *
+ * @author <a href="mailto:pim.moerenhout@gmail.com">Pim Moerenhout</a>
+ * @since 3.1.2
+ */
+@Mojo( name = "list-plugin-repositories", requiresDependencyResolution = ResolutionScope.TEST, threadSafe = true )
+public class ListPluginRepositoriesMojo
+    extends AbstractDependencyMojo
+{
+    /**
+     * Maven Project Builder component.
+    */
+    @Component
+    private ProjectBuilder projectBuilder;
+
+    /**
+     * Component used to resolve artifacts and download their files from remote repositories.
+     */
+    @Component
+    private ArtifactResolver artifactResolver;
+
+    /**
+     * The system settings for Maven. This is the instance resulting from
+     * merging global and user-level settings files.
+     */
+    @Parameter( defaultValue = "${settings}", readonly = true, required = true )
+    private Settings settings;
+
+    /**
+     * Plugin repositories used for the project.
+     */
+    @Parameter( defaultValue = "${project.pluginArtifactRepositories}", readonly = true, required = true )
+    private List<ArtifactRepository> pluginRepositories;
+
+    /**
+     * Sets whether the plugin runs in verbose mode. As of plugin version 2.3, the default value is derived from Maven's
+     * global debug flag (compare command line switch <code>-X</code>).
+     *
+     * @since 3.1.2
+     */
+    @Parameter( property = "verbose" )
+    private boolean verbose;
+
+    /**
+     * Displays a list of the plugin repositories used by this build.
+     *
+     * @throws MojoExecutionException with a message if an error occurs.
+     */
+    @Override
+    protected void doExecute()
+        throws MojoExecutionException
+    {
+        final List<ArtifactRepository> repositories = pluginRepositories;
+        final Set<Artifact> artifacts = getProject().getPluginArtifacts();
+
+        this.getLog().info( "Plugin repositories used by this build:" );
+        for ( ArtifactRepository repo : repositories )
+        {
+            if ( isVerbose() )
+            {
+                Set<String> locations = new HashSet<String>();
+                for ( Mirror mirror : settings.getMirrors() )
+                {
+                    if ( mirror.getId().equals( repo.getId() )
+                        && ( mirror.getUrl().equals( repo.getUrl() ) ) )
+                    {
+                        locations.add( "Maven settings (user/global)" );
+                    }
+                }
+
+                Artifact projectArtifact = getProject().getArtifact();
+                MavenProject project = getMavenProject( ArtifactUtils.key( projectArtifact ) );
+                traversePom( repo, projectArtifact, project, locations );
+
+                for ( Artifact artifact : artifacts )
+                {
+                    MavenProject artifactProject = getMavenProject( ArtifactUtils.key( artifact ) );
+                    traversePom( repo, artifact, artifactProject, locations );
+                }
+                writeRepository( repo, locations );
+            }
+            else
+            {
+                this.getLog().info( repo.toString() );
+            }
+        }
+    }
+
+    private void writeRepository( ArtifactRepository artifactRepository, Set<String> locations )
+    {
+        StringBuilder sb = new StringBuilder( 256 );
+        sb.append( artifactRepository.toString() );
+        for ( String location : locations )
+        {
+            sb.append( " location: " ).append( location ).append( System.lineSeparator() );
+        }
+        this.getLog().info( sb.toString() );
+    }
+
+    /**
+     * Parses the given String into GAV artifact coordinate information, adding the given type.
+     *
+     * @param artifactString should respect the format <code>groupId:artifactId[:version]</code>
+     * @param type The extension for the artifact, must not be <code>null</code>.
+     * @return the <code>Artifact</code> object for the <code>artifactString</code> parameter.
+     * @throws MojoExecutionException if the <code>artifactString</code> doesn't respect the format.
+     */
+    private ArtifactCoordinate getArtifactCoordinate( String artifactString, String type )
+        throws MojoExecutionException
+    {
+        if ( org.codehaus.plexus.util.StringUtils.isEmpty( artifactString ) )
+        {
+            throw new IllegalArgumentException( "artifact parameter could not be empty" );
+        }
+
+        String groupId; // required
+        String artifactId; // required
+        String version; // optional
+
+        String[] artifactParts = artifactString.split( ":" );
+        switch ( artifactParts.length )
+        {
+            case 2:
+                groupId = artifactParts[0];
+                artifactId = artifactParts[1];
+                version = Artifact.LATEST_VERSION;
+                break;
+            case 3:
+                groupId = artifactParts[0];
+                artifactId = artifactParts[1];
+                version = artifactParts[2];
+                break;
+            default:
+                throw new MojoExecutionException( "The artifact parameter '" + artifactString
+                    + "' should be conform to: " + "'groupId:artifactId[:version]'." );
+        }
+        return getArtifactCoordinate( groupId, artifactId, version, type );
+    }
+
+    private ArtifactCoordinate getArtifactCoordinate( String groupId, String artifactId, String version, String type )
+    {
+        DefaultArtifactCoordinate coordinate = new DefaultArtifactCoordinate();
+        coordinate.setGroupId( groupId );
+        coordinate.setArtifactId( artifactId );
+        coordinate.setVersion( version );
+        coordinate.setExtension( type );
+        return coordinate;
+    }
+
+    /**
+     * Retrieves the Maven Project associated with the given artifact String, in the form of
+     * <code>groupId:artifactId[:version]</code>. This resolves the POM artifact at those coordinates and then builds
+     * the Maven project from it.
+     *
+     * @param artifactString Coordinates of the Maven project to get.
+     * @return New Maven project.

Review comment:
       no period, no cap

##########
File path: src/site/apt/usage.apt.vm
##########
@@ -688,6 +688,24 @@ mvn dependency:build-classpath -Dmdep.outputFile=cp.txt
   poms and declared in transitive dependency poms.
 
 
+* <<<dependency:list-repositories>>>
+
+  This goal is used to list all the plugin repositories that this build depends upon. It will show plugin repositories defined in your settings,

Review comment:
       is used to list --> lists
   will show --> shows

##########
File path: src/site/apt/usage.apt.vm
##########
@@ -688,6 +688,24 @@ mvn dependency:build-classpath -Dmdep.outputFile=cp.txt
   poms and declared in transitive dependency poms.
 
 
+* <<<dependency:list-repositories>>>
+
+  This goal is used to list all the plugin repositories that this build depends upon. It will show plugin repositories defined in your settings,
+  poms and declared in transitive dependency poms.
+
+  This goal can be executed from the command line:
+
++-----+
+mvn dependency:list-plugin-repositories
++-----+
+
+  Optionally, in verbose or debug mode it will display the location of the listed plugin repository:

Review comment:
       will display --> displays
   (Tech writing lives in the eternal present.)

##########
File path: src/test/java/org/apache/maven/plugins/dependency/AbstractDependencyMojoTest.java
##########
@@ -0,0 +1,148 @@
+package org.apache.maven.plugins.dependency;
+
+/*
+ * 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 junit.framework.TestCase;
+import org.apache.maven.artifact.repository.ArtifactRepository;
+import org.apache.maven.execution.MavenSession;
+import org.apache.maven.project.ProjectBuildingRequest;
+
+import java.lang.reflect.Field;
+import java.util.ArrayList;
+import java.util.List;
+
+import static org.apache.maven.plugins.dependency.AbstractDependencyMojoTest.ConcreteDependencyMojo.createConcreteDependencyMojoWithArtifactRepositories;
+import static org.apache.maven.plugins.dependency.AbstractDependencyMojoTest.ConcreteDependencyMojo.createConcreteDependencyMojoWithPluginRepositories;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
+public class AbstractDependencyMojoTest extends TestCase
+{
+    private MavenSession session = mock( MavenSession.class );
+
+    private ProjectBuildingRequest buildingRequest = mock( ProjectBuildingRequest.class );
+
+    private ArrayList<ArtifactRepository> artifactRepos = new ArrayList<>();
+
+    private ArrayList<ArtifactRepository> pluginRepos = new ArrayList<>();
+
+    static class ConcreteDependencyMojo extends AbstractDependencyMojo
+    {
+        static ConcreteDependencyMojo createConcreteDependencyMojoWithArtifactRepositories(
+                MavenSession mavenSession, List<ArtifactRepository> artifactRepos )
+                throws NoSuchFieldException, IllegalAccessException
+        {
+            ConcreteDependencyMojo cdm = new ConcreteDependencyMojo();
+            cdm.session = mavenSession;
+
+            Field par = AbstractDependencyMojo.class.getDeclaredField( "remoteRepositories" );

Review comment:
       what is "par"? perhaps a more descriptive name?

##########
File path: src/main/java/org/apache/maven/plugins/dependency/resolvers/ListPluginRepositoriesMojo.java
##########
@@ -0,0 +1,323 @@
+package org.apache.maven.plugins.dependency.resolvers;
+
+/*
+ * 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 java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import org.apache.maven.artifact.Artifact;
+import org.apache.maven.artifact.ArtifactUtils;
+import org.apache.maven.artifact.repository.ArtifactRepository;
+import org.apache.maven.model.Model;
+import org.apache.maven.model.Repository;
+import org.apache.maven.model.building.ModelBuildingRequest;
+import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.plugins.annotations.Component;
+import org.apache.maven.plugins.annotations.Mojo;
+import org.apache.maven.plugins.annotations.Parameter;
+import org.apache.maven.plugins.annotations.ResolutionScope;
+import org.apache.maven.plugins.dependency.AbstractDependencyMojo;
+import org.apache.maven.project.DefaultProjectBuildingRequest;
+import org.apache.maven.project.MavenProject;
+import org.apache.maven.project.ProjectBuilder;
+import org.apache.maven.project.ProjectBuildingRequest;
+import org.apache.maven.settings.Mirror;
+import org.apache.maven.settings.Settings;
+import org.apache.maven.shared.transfer.artifact.ArtifactCoordinate;
+import org.apache.maven.shared.transfer.artifact.DefaultArtifactCoordinate;
+import org.apache.maven.shared.transfer.artifact.resolve.ArtifactResolver;
+
+/**
+ * Goal that resolves all project plugin dependencies and then lists the repositories used by the build
+ *
+ * @author <a href="mailto:pim.moerenhout@gmail.com">Pim Moerenhout</a>
+ * @since 3.1.2
+ */
+@Mojo( name = "list-plugin-repositories", requiresDependencyResolution = ResolutionScope.TEST, threadSafe = true )
+public class ListPluginRepositoriesMojo
+    extends AbstractDependencyMojo
+{
+    /**
+     * Maven Project Builder component.
+    */
+    @Component
+    private ProjectBuilder projectBuilder;
+
+    /**
+     * Component used to resolve artifacts and download their files from remote repositories.
+     */
+    @Component
+    private ArtifactResolver artifactResolver;
+
+    /**
+     * The system settings for Maven. This is the instance resulting from
+     * merging global and user-level settings files.
+     */
+    @Parameter( defaultValue = "${settings}", readonly = true, required = true )
+    private Settings settings;
+
+    /**
+     * Plugin repositories used for the project.
+     */
+    @Parameter( defaultValue = "${project.pluginArtifactRepositories}", readonly = true, required = true )
+    private List<ArtifactRepository> pluginRepositories;
+
+    /**
+     * Sets whether the plugin runs in verbose mode. As of plugin version 2.3, the default value is derived from Maven's
+     * global debug flag (compare command line switch <code>-X</code>).
+     *
+     * @since 3.1.2
+     */
+    @Parameter( property = "verbose" )
+    private boolean verbose;
+
+    /**
+     * Displays a list of the plugin repositories used by this build.
+     *
+     * @throws MojoExecutionException with a message if an error occurs.
+     */
+    @Override
+    protected void doExecute()
+        throws MojoExecutionException
+    {
+        final List<ArtifactRepository> repositories = pluginRepositories;
+        final Set<Artifact> artifacts = getProject().getPluginArtifacts();
+
+        this.getLog().info( "Plugin repositories used by this build:" );
+        for ( ArtifactRepository repo : repositories )
+        {
+            if ( isVerbose() )
+            {
+                Set<String> locations = new HashSet<String>();
+                for ( Mirror mirror : settings.getMirrors() )
+                {
+                    if ( mirror.getId().equals( repo.getId() )
+                        && ( mirror.getUrl().equals( repo.getUrl() ) ) )
+                    {
+                        locations.add( "Maven settings (user/global)" );
+                    }
+                }
+
+                Artifact projectArtifact = getProject().getArtifact();
+                MavenProject project = getMavenProject( ArtifactUtils.key( projectArtifact ) );
+                traversePom( repo, projectArtifact, project, locations );
+
+                for ( Artifact artifact : artifacts )
+                {
+                    MavenProject artifactProject = getMavenProject( ArtifactUtils.key( artifact ) );
+                    traversePom( repo, artifact, artifactProject, locations );
+                }
+                writeRepository( repo, locations );
+            }
+            else
+            {
+                this.getLog().info( repo.toString() );
+            }
+        }
+    }
+
+    private void writeRepository( ArtifactRepository artifactRepository, Set<String> locations )
+    {
+        StringBuilder sb = new StringBuilder( 256 );
+        sb.append( artifactRepository.toString() );
+        for ( String location : locations )
+        {
+            sb.append( " location: " ).append( location ).append( System.lineSeparator() );
+        }
+        this.getLog().info( sb.toString() );
+    }
+
+    /**
+     * Parses the given String into GAV artifact coordinate information, adding the given type.
+     *
+     * @param artifactString should respect the format <code>groupId:artifactId[:version]</code>
+     * @param type The extension for the artifact, must not be <code>null</code>.
+     * @return the <code>Artifact</code> object for the <code>artifactString</code> parameter.
+     * @throws MojoExecutionException if the <code>artifactString</code> doesn't respect the format.
+     */
+    private ArtifactCoordinate getArtifactCoordinate( String artifactString, String type )
+        throws MojoExecutionException
+    {
+        if ( org.codehaus.plexus.util.StringUtils.isEmpty( artifactString ) )
+        {
+            throw new IllegalArgumentException( "artifact parameter could not be empty" );

Review comment:
       could not be --> is 

##########
File path: src/main/java/org/apache/maven/plugins/dependency/resolvers/ListPluginRepositoriesMojo.java
##########
@@ -0,0 +1,323 @@
+package org.apache.maven.plugins.dependency.resolvers;
+
+/*
+ * 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 java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import org.apache.maven.artifact.Artifact;
+import org.apache.maven.artifact.ArtifactUtils;
+import org.apache.maven.artifact.repository.ArtifactRepository;
+import org.apache.maven.model.Model;
+import org.apache.maven.model.Repository;
+import org.apache.maven.model.building.ModelBuildingRequest;
+import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.plugins.annotations.Component;
+import org.apache.maven.plugins.annotations.Mojo;
+import org.apache.maven.plugins.annotations.Parameter;
+import org.apache.maven.plugins.annotations.ResolutionScope;
+import org.apache.maven.plugins.dependency.AbstractDependencyMojo;
+import org.apache.maven.project.DefaultProjectBuildingRequest;
+import org.apache.maven.project.MavenProject;
+import org.apache.maven.project.ProjectBuilder;
+import org.apache.maven.project.ProjectBuildingRequest;
+import org.apache.maven.settings.Mirror;
+import org.apache.maven.settings.Settings;
+import org.apache.maven.shared.transfer.artifact.ArtifactCoordinate;
+import org.apache.maven.shared.transfer.artifact.DefaultArtifactCoordinate;
+import org.apache.maven.shared.transfer.artifact.resolve.ArtifactResolver;
+
+/**
+ * Goal that resolves all project plugin dependencies and then lists the repositories used by the build
+ *
+ * @author <a href="mailto:pim.moerenhout@gmail.com">Pim Moerenhout</a>
+ * @since 3.1.2
+ */
+@Mojo( name = "list-plugin-repositories", requiresDependencyResolution = ResolutionScope.TEST, threadSafe = true )
+public class ListPluginRepositoriesMojo
+    extends AbstractDependencyMojo
+{
+    /**
+     * Maven Project Builder component.
+    */
+    @Component
+    private ProjectBuilder projectBuilder;
+
+    /**
+     * Component used to resolve artifacts and download their files from remote repositories.
+     */
+    @Component
+    private ArtifactResolver artifactResolver;
+
+    /**
+     * The system settings for Maven. This is the instance resulting from
+     * merging global and user-level settings files.
+     */
+    @Parameter( defaultValue = "${settings}", readonly = true, required = true )
+    private Settings settings;
+
+    /**
+     * Plugin repositories used for the project.
+     */
+    @Parameter( defaultValue = "${project.pluginArtifactRepositories}", readonly = true, required = true )
+    private List<ArtifactRepository> pluginRepositories;
+
+    /**
+     * Sets whether the plugin runs in verbose mode. As of plugin version 2.3, the default value is derived from Maven's
+     * global debug flag (compare command line switch <code>-X</code>).
+     *
+     * @since 3.1.2
+     */
+    @Parameter( property = "verbose" )
+    private boolean verbose;
+
+    /**
+     * Displays a list of the plugin repositories used by this build.
+     *
+     * @throws MojoExecutionException with a message if an error occurs.
+     */
+    @Override
+    protected void doExecute()
+        throws MojoExecutionException
+    {
+        final List<ArtifactRepository> repositories = pluginRepositories;
+        final Set<Artifact> artifacts = getProject().getPluginArtifacts();
+
+        this.getLog().info( "Plugin repositories used by this build:" );
+        for ( ArtifactRepository repo : repositories )
+        {
+            if ( isVerbose() )
+            {
+                Set<String> locations = new HashSet<String>();
+                for ( Mirror mirror : settings.getMirrors() )
+                {
+                    if ( mirror.getId().equals( repo.getId() )
+                        && ( mirror.getUrl().equals( repo.getUrl() ) ) )
+                    {
+                        locations.add( "Maven settings (user/global)" );
+                    }
+                }
+
+                Artifact projectArtifact = getProject().getArtifact();
+                MavenProject project = getMavenProject( ArtifactUtils.key( projectArtifact ) );
+                traversePom( repo, projectArtifact, project, locations );
+
+                for ( Artifact artifact : artifacts )
+                {
+                    MavenProject artifactProject = getMavenProject( ArtifactUtils.key( artifact ) );
+                    traversePom( repo, artifact, artifactProject, locations );
+                }
+                writeRepository( repo, locations );
+            }
+            else
+            {
+                this.getLog().info( repo.toString() );
+            }
+        }
+    }
+
+    private void writeRepository( ArtifactRepository artifactRepository, Set<String> locations )
+    {
+        StringBuilder sb = new StringBuilder( 256 );
+        sb.append( artifactRepository.toString() );
+        for ( String location : locations )
+        {
+            sb.append( " location: " ).append( location ).append( System.lineSeparator() );
+        }
+        this.getLog().info( sb.toString() );
+    }
+
+    /**
+     * Parses the given String into GAV artifact coordinate information, adding the given type.
+     *
+     * @param artifactString should respect the format <code>groupId:artifactId[:version]</code>
+     * @param type The extension for the artifact, must not be <code>null</code>.

Review comment:
       nit: The --> the and no period, per Oracle JavaDoc guidelines

##########
File path: src/main/java/org/apache/maven/plugins/dependency/resolvers/ListPluginRepositoriesMojo.java
##########
@@ -0,0 +1,323 @@
+package org.apache.maven.plugins.dependency.resolvers;
+
+/*
+ * 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 java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import org.apache.maven.artifact.Artifact;
+import org.apache.maven.artifact.ArtifactUtils;
+import org.apache.maven.artifact.repository.ArtifactRepository;
+import org.apache.maven.model.Model;
+import org.apache.maven.model.Repository;
+import org.apache.maven.model.building.ModelBuildingRequest;
+import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.plugins.annotations.Component;
+import org.apache.maven.plugins.annotations.Mojo;
+import org.apache.maven.plugins.annotations.Parameter;
+import org.apache.maven.plugins.annotations.ResolutionScope;
+import org.apache.maven.plugins.dependency.AbstractDependencyMojo;
+import org.apache.maven.project.DefaultProjectBuildingRequest;
+import org.apache.maven.project.MavenProject;
+import org.apache.maven.project.ProjectBuilder;
+import org.apache.maven.project.ProjectBuildingRequest;
+import org.apache.maven.settings.Mirror;
+import org.apache.maven.settings.Settings;
+import org.apache.maven.shared.transfer.artifact.ArtifactCoordinate;
+import org.apache.maven.shared.transfer.artifact.DefaultArtifactCoordinate;
+import org.apache.maven.shared.transfer.artifact.resolve.ArtifactResolver;
+
+/**
+ * Goal that resolves all project plugin dependencies and then lists the repositories used by the build
+ *
+ * @author <a href="mailto:pim.moerenhout@gmail.com">Pim Moerenhout</a>
+ * @since 3.1.2
+ */
+@Mojo( name = "list-plugin-repositories", requiresDependencyResolution = ResolutionScope.TEST, threadSafe = true )
+public class ListPluginRepositoriesMojo
+    extends AbstractDependencyMojo
+{
+    /**
+     * Maven Project Builder component.
+    */
+    @Component
+    private ProjectBuilder projectBuilder;
+
+    /**
+     * Component used to resolve artifacts and download their files from remote repositories.
+     */
+    @Component
+    private ArtifactResolver artifactResolver;
+
+    /**
+     * The system settings for Maven. This is the instance resulting from
+     * merging global and user-level settings files.
+     */
+    @Parameter( defaultValue = "${settings}", readonly = true, required = true )
+    private Settings settings;
+
+    /**
+     * Plugin repositories used for the project.
+     */
+    @Parameter( defaultValue = "${project.pluginArtifactRepositories}", readonly = true, required = true )
+    private List<ArtifactRepository> pluginRepositories;
+
+    /**
+     * Sets whether the plugin runs in verbose mode. As of plugin version 2.3, the default value is derived from Maven's
+     * global debug flag (compare command line switch <code>-X</code>).
+     *
+     * @since 3.1.2
+     */
+    @Parameter( property = "verbose" )
+    private boolean verbose;
+
+    /**
+     * Displays a list of the plugin repositories used by this build.
+     *
+     * @throws MojoExecutionException with a message if an error occurs.
+     */
+    @Override
+    protected void doExecute()
+        throws MojoExecutionException
+    {
+        final List<ArtifactRepository> repositories = pluginRepositories;
+        final Set<Artifact> artifacts = getProject().getPluginArtifacts();
+
+        this.getLog().info( "Plugin repositories used by this build:" );
+        for ( ArtifactRepository repo : repositories )
+        {
+            if ( isVerbose() )
+            {
+                Set<String> locations = new HashSet<String>();
+                for ( Mirror mirror : settings.getMirrors() )
+                {
+                    if ( mirror.getId().equals( repo.getId() )
+                        && ( mirror.getUrl().equals( repo.getUrl() ) ) )
+                    {
+                        locations.add( "Maven settings (user/global)" );
+                    }
+                }
+
+                Artifact projectArtifact = getProject().getArtifact();
+                MavenProject project = getMavenProject( ArtifactUtils.key( projectArtifact ) );
+                traversePom( repo, projectArtifact, project, locations );
+
+                for ( Artifact artifact : artifacts )
+                {
+                    MavenProject artifactProject = getMavenProject( ArtifactUtils.key( artifact ) );
+                    traversePom( repo, artifact, artifactProject, locations );
+                }
+                writeRepository( repo, locations );
+            }
+            else
+            {
+                this.getLog().info( repo.toString() );
+            }
+        }
+    }
+
+    private void writeRepository( ArtifactRepository artifactRepository, Set<String> locations )
+    {
+        StringBuilder sb = new StringBuilder( 256 );
+        sb.append( artifactRepository.toString() );
+        for ( String location : locations )
+        {
+            sb.append( " location: " ).append( location ).append( System.lineSeparator() );
+        }
+        this.getLog().info( sb.toString() );
+    }
+
+    /**
+     * Parses the given String into GAV artifact coordinate information, adding the given type.
+     *
+     * @param artifactString should respect the format <code>groupId:artifactId[:version]</code>
+     * @param type The extension for the artifact, must not be <code>null</code>.
+     * @return the <code>Artifact</code> object for the <code>artifactString</code> parameter.
+     * @throws MojoExecutionException if the <code>artifactString</code> doesn't respect the format.
+     */
+    private ArtifactCoordinate getArtifactCoordinate( String artifactString, String type )
+        throws MojoExecutionException
+    {
+        if ( org.codehaus.plexus.util.StringUtils.isEmpty( artifactString ) )
+        {
+            throw new IllegalArgumentException( "artifact parameter could not be empty" );
+        }
+
+        String groupId; // required
+        String artifactId; // required
+        String version; // optional
+
+        String[] artifactParts = artifactString.split( ":" );
+        switch ( artifactParts.length )
+        {
+            case 2:
+                groupId = artifactParts[0];
+                artifactId = artifactParts[1];
+                version = Artifact.LATEST_VERSION;
+                break;
+            case 3:
+                groupId = artifactParts[0];
+                artifactId = artifactParts[1];
+                version = artifactParts[2];
+                break;
+            default:
+                throw new MojoExecutionException( "The artifact parameter '" + artifactString
+                    + "' should be conform to: " + "'groupId:artifactId[:version]'." );
+        }
+        return getArtifactCoordinate( groupId, artifactId, version, type );
+    }
+
+    private ArtifactCoordinate getArtifactCoordinate( String groupId, String artifactId, String version, String type )
+    {
+        DefaultArtifactCoordinate coordinate = new DefaultArtifactCoordinate();
+        coordinate.setGroupId( groupId );
+        coordinate.setArtifactId( artifactId );
+        coordinate.setVersion( version );
+        coordinate.setExtension( type );
+        return coordinate;
+    }
+
+    /**
+     * Retrieves the Maven Project associated with the given artifact String, in the form of
+     * <code>groupId:artifactId[:version]</code>. This resolves the POM artifact at those coordinates and then builds
+     * the Maven project from it.
+     *
+     * @param artifactString Coordinates of the Maven project to get.
+     * @return New Maven project.
+     * @throws MojoExecutionException If there was an error while getting the Maven project.

Review comment:
       no period, no cap

##########
File path: src/main/java/org/apache/maven/plugins/dependency/resolvers/ListPluginRepositoriesMojo.java
##########
@@ -0,0 +1,323 @@
+package org.apache.maven.plugins.dependency.resolvers;
+
+/*
+ * 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 java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import org.apache.maven.artifact.Artifact;
+import org.apache.maven.artifact.ArtifactUtils;
+import org.apache.maven.artifact.repository.ArtifactRepository;
+import org.apache.maven.model.Model;
+import org.apache.maven.model.Repository;
+import org.apache.maven.model.building.ModelBuildingRequest;
+import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.plugins.annotations.Component;
+import org.apache.maven.plugins.annotations.Mojo;
+import org.apache.maven.plugins.annotations.Parameter;
+import org.apache.maven.plugins.annotations.ResolutionScope;
+import org.apache.maven.plugins.dependency.AbstractDependencyMojo;
+import org.apache.maven.project.DefaultProjectBuildingRequest;
+import org.apache.maven.project.MavenProject;
+import org.apache.maven.project.ProjectBuilder;
+import org.apache.maven.project.ProjectBuildingRequest;
+import org.apache.maven.settings.Mirror;
+import org.apache.maven.settings.Settings;
+import org.apache.maven.shared.transfer.artifact.ArtifactCoordinate;
+import org.apache.maven.shared.transfer.artifact.DefaultArtifactCoordinate;
+import org.apache.maven.shared.transfer.artifact.resolve.ArtifactResolver;
+
+/**
+ * Goal that resolves all project plugin dependencies and then lists the repositories used by the build
+ *
+ * @author <a href="mailto:pim.moerenhout@gmail.com">Pim Moerenhout</a>
+ * @since 3.1.2
+ */
+@Mojo( name = "list-plugin-repositories", requiresDependencyResolution = ResolutionScope.TEST, threadSafe = true )
+public class ListPluginRepositoriesMojo
+    extends AbstractDependencyMojo
+{
+    /**
+     * Maven Project Builder component.
+    */
+    @Component
+    private ProjectBuilder projectBuilder;
+
+    /**
+     * Component used to resolve artifacts and download their files from remote repositories.
+     */
+    @Component
+    private ArtifactResolver artifactResolver;
+
+    /**
+     * The system settings for Maven. This is the instance resulting from
+     * merging global and user-level settings files.
+     */
+    @Parameter( defaultValue = "${settings}", readonly = true, required = true )
+    private Settings settings;
+
+    /**
+     * Plugin repositories used for the project.
+     */
+    @Parameter( defaultValue = "${project.pluginArtifactRepositories}", readonly = true, required = true )
+    private List<ArtifactRepository> pluginRepositories;
+
+    /**
+     * Sets whether the plugin runs in verbose mode. As of plugin version 2.3, the default value is derived from Maven's
+     * global debug flag (compare command line switch <code>-X</code>).
+     *
+     * @since 3.1.2
+     */
+    @Parameter( property = "verbose" )
+    private boolean verbose;
+
+    /**
+     * Displays a list of the plugin repositories used by this build.
+     *
+     * @throws MojoExecutionException with a message if an error occurs.
+     */
+    @Override
+    protected void doExecute()
+        throws MojoExecutionException
+    {
+        final List<ArtifactRepository> repositories = pluginRepositories;
+        final Set<Artifact> artifacts = getProject().getPluginArtifacts();
+
+        this.getLog().info( "Plugin repositories used by this build:" );
+        for ( ArtifactRepository repo : repositories )
+        {
+            if ( isVerbose() )
+            {
+                Set<String> locations = new HashSet<String>();
+                for ( Mirror mirror : settings.getMirrors() )
+                {
+                    if ( mirror.getId().equals( repo.getId() )
+                        && ( mirror.getUrl().equals( repo.getUrl() ) ) )
+                    {
+                        locations.add( "Maven settings (user/global)" );
+                    }
+                }
+
+                Artifact projectArtifact = getProject().getArtifact();
+                MavenProject project = getMavenProject( ArtifactUtils.key( projectArtifact ) );
+                traversePom( repo, projectArtifact, project, locations );
+
+                for ( Artifact artifact : artifacts )
+                {
+                    MavenProject artifactProject = getMavenProject( ArtifactUtils.key( artifact ) );
+                    traversePom( repo, artifact, artifactProject, locations );
+                }
+                writeRepository( repo, locations );
+            }
+            else
+            {
+                this.getLog().info( repo.toString() );
+            }
+        }
+    }
+
+    private void writeRepository( ArtifactRepository artifactRepository, Set<String> locations )
+    {
+        StringBuilder sb = new StringBuilder( 256 );
+        sb.append( artifactRepository.toString() );
+        for ( String location : locations )
+        {
+            sb.append( " location: " ).append( location ).append( System.lineSeparator() );
+        }
+        this.getLog().info( sb.toString() );
+    }
+
+    /**
+     * Parses the given String into GAV artifact coordinate information, adding the given type.
+     *
+     * @param artifactString should respect the format <code>groupId:artifactId[:version]</code>
+     * @param type The extension for the artifact, must not be <code>null</code>.
+     * @return the <code>Artifact</code> object for the <code>artifactString</code> parameter.
+     * @throws MojoExecutionException if the <code>artifactString</code> doesn't respect the format.
+     */
+    private ArtifactCoordinate getArtifactCoordinate( String artifactString, String type )
+        throws MojoExecutionException
+    {
+        if ( org.codehaus.plexus.util.StringUtils.isEmpty( artifactString ) )

Review comment:
       Please use apache commons stringutils instead




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org