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/05/27 03:42:13 UTC

[GitHub] [maven-dependency-plugin] jonvolfson opened a new pull request #57: Created new mojo GetClassesMojo which lists all class dependencies for a specified artifact.

jonvolfson opened a new pull request #57:
URL: https://github.com/apache/maven-dependency-plugin/pull/57


   @elharo @bimargulies 
   


----------------------------------------------------------------
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



[GitHub] [maven-dependency-plugin] elharo commented on a change in pull request #57: [MDEP-645] Created new mojo GetClassesMojo which lists all class dependencies for a specified artifact.

Posted by GitBox <gi...@apache.org>.
elharo commented on a change in pull request #57:
URL: https://github.com/apache/maven-dependency-plugin/pull/57#discussion_r431398044



##########
File path: src/test/java/org/apache/maven/plugins/dependency/TestGetClassesMojo.java
##########
@@ -0,0 +1,86 @@
+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 org.apache.maven.execution.MavenSession;
+import org.apache.maven.plugin.LegacySupport;
+import org.apache.maven.plugin.testing.stubs.MavenProjectStub;
+import org.apache.maven.settings.Server;
+import org.apache.maven.settings.Settings;
+import org.sonatype.aether.impl.internal.SimpleLocalRepositoryManager;

Review comment:
       Not off the top of my head but try calling `lookup(LocalRepositoryManager.class)` in the setUp method and see if that returns an object that works. 




----------------------------------------------------------------
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



[GitHub] [maven-dependency-plugin] jonvolfson commented on a change in pull request #57: [MDEP-645] Created new mojo GetClassesMojo which lists all class dependencies for a specified artifact.

Posted by GitBox <gi...@apache.org>.
jonvolfson commented on a change in pull request #57:
URL: https://github.com/apache/maven-dependency-plugin/pull/57#discussion_r441031441



##########
File path: src/main/java/org/apache/maven/plugins/dependency/GetClassesMojo.java
##########
@@ -0,0 +1,406 @@
+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;
+import org.codehaus.plexus.util.StringUtils;

Review comment:
       fixed




----------------------------------------------------------------
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



[GitHub] [maven-dependency-plugin] jonvolfson commented on a change in pull request #57: [MDEP-645] Created new mojo GetClassesMojo which lists all class dependencies for a specified artifact.

Posted by GitBox <gi...@apache.org>.
jonvolfson commented on a change in pull request #57:
URL: https://github.com/apache/maven-dependency-plugin/pull/57#discussion_r431277013



##########
File path: src/main/java/org/apache/maven/plugins/dependency/ListClassesMojo.java
##########
@@ -0,0 +1,402 @@
+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. ie.
+     * 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 = buildBuildingRequest();
+        DefaultDependableCoordinate coordinate = getCoordinate();
+
+        try
+        {
+            if ( isTransitive() )
+            {
+                Iterable<ArtifactResult> artifacts = getDependencyResolver()
+                        .resolveDependencies( buildingRequest, coordinate, null );
+
+                for ( ArtifactResult result : artifacts )
+                {
+                    printClassesFromArtifactResult( result );
+                }
+            }
+            else
+            {
+                ArtifactResult result = getArtifactResolver()
+                        .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
+    {
+        JarFile jarFile = new JarFile( result.getArtifact().getFile() );
+        Enumeration entries = jarFile.entries();
+
+        while ( entries.hasMoreElements() )
+        {
+            JarEntry entry = (JarEntry) entries.nextElement();
+            String name = entry.getName();
+
+            // filter out files that do not end in .class
+            if ( !name.endsWith( ".class" ) )
+            {
+                continue;
+            }
+
+            // remove .class from the end and change format to use periods instead of forward slashes
+            name = name.substring( 0, name.length() - 6 ).replace( '/', '.' );
+            getLog().info( name );
+        }
+        jarFile.close();
+    }
+
+    private ProjectBuildingRequest buildBuildingRequest()
+            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 )
+    {
+        ArtifactHandler artifactHandler = artifactHandlerManager.getArtifactHandler( dependableCoordinate.getType() );
+        DefaultArtifactCoordinate artifactCoordinate = new DefaultArtifactCoordinate();
+        artifactCoordinate.setGroupId( dependableCoordinate.getGroupId() );
+        artifactCoordinate.setArtifactId( dependableCoordinate.getArtifactId() );
+        artifactCoordinate.setVersion( dependableCoordinate.getVersion() );
+        artifactCoordinate.setClassifier( dependableCoordinate.getClassifier() );
+        artifactCoordinate.setExtension( artifactHandler.getExtension() );
+        return artifactCoordinate;
+    }
+
+    ArtifactRepository parseRepository( String repo, ArtifactRepositoryPolicy policy )
+            throws MojoFailureException
+    {
+        // if it's a simple url
+        String id = "temp";
+        ArtifactRepositoryLayout layout = getLayout( "default" );
+
+        // if it's an extended repo URL of the form id::layout::url
+        if ( repo.contains( "::" ) )
+        {
+            Matcher matcher = ALT_REPO_SYNTAX_PATTERN.matcher( repo );
+            if ( !matcher.matches() )
+            {
+                throw new MojoFailureException( repo, "Invalid syntax for repository: " + repo,
+                        "Invalid syntax for repository. Use \"id::layout::url\" or \"URL\"." );
+            }
+
+            id = matcher.group( 1 ).trim();
+            if ( !( matcher.group( 2 ) == null || matcher.group( 2 ).trim().isEmpty() ) )
+            {
+                layout = getLayout( matcher.group( 2 ).trim() );
+            }
+            repo = matcher.group( 3 ).trim();
+        }
+        return new MavenArtifactRepository( id, repo, layout, policy, policy );
+    }
+
+    private ArtifactRepositoryLayout getLayout( String id )
+            throws MojoFailureException
+    {
+        ArtifactRepositoryLayout layout = repositoryLayouts.get( id );
+
+        if ( layout == null )
+        {
+            throw new MojoFailureException( id, "Invalid repository layout", "Invalid repository layout: " + id );
+        }
+
+        return layout;
+    }
+
+    /**
+     * @return {@link #skip}
+     */
+    protected boolean isSkip()
+    {
+        return skip;
+    }
+
+    protected boolean isTransitive()
+    {
+        return transitive;
+    }
+
+    protected DefaultDependableCoordinate getCoordinate()
+    {
+        return coordinate;
+    }
+
+    protected DependencyResolver getDependencyResolver()
+    {
+        return dependencyResolver;
+    }
+
+    protected ArtifactResolver getArtifactResolver()
+    {
+        return artifactResolver;
+    }
+
+    /**
+     * @param artifact The artifact.

Review comment:
       fixed

##########
File path: src/main/java/org/apache/maven/plugins/dependency/ListClassesMojo.java
##########
@@ -0,0 +1,402 @@
+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. ie.
+     * 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 = buildBuildingRequest();
+        DefaultDependableCoordinate coordinate = getCoordinate();
+
+        try
+        {
+            if ( isTransitive() )
+            {
+                Iterable<ArtifactResult> artifacts = getDependencyResolver()
+                        .resolveDependencies( buildingRequest, coordinate, null );
+
+                for ( ArtifactResult result : artifacts )
+                {
+                    printClassesFromArtifactResult( result );
+                }
+            }
+            else
+            {
+                ArtifactResult result = getArtifactResolver()
+                        .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
+    {
+        JarFile jarFile = new JarFile( result.getArtifact().getFile() );
+        Enumeration entries = jarFile.entries();
+
+        while ( entries.hasMoreElements() )
+        {
+            JarEntry entry = (JarEntry) entries.nextElement();
+            String name = entry.getName();
+
+            // filter out files that do not end in .class
+            if ( !name.endsWith( ".class" ) )
+            {
+                continue;
+            }
+
+            // remove .class from the end and change format to use periods instead of forward slashes
+            name = name.substring( 0, name.length() - 6 ).replace( '/', '.' );

Review comment:
       fixed

##########
File path: src/main/java/org/apache/maven/plugins/dependency/ListClassesMojo.java
##########
@@ -0,0 +1,402 @@
+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. ie.
+     * 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 = buildBuildingRequest();
+        DefaultDependableCoordinate coordinate = getCoordinate();
+
+        try
+        {
+            if ( isTransitive() )
+            {
+                Iterable<ArtifactResult> artifacts = getDependencyResolver()
+                        .resolveDependencies( buildingRequest, coordinate, null );
+
+                for ( ArtifactResult result : artifacts )
+                {
+                    printClassesFromArtifactResult( result );
+                }
+            }
+            else
+            {
+                ArtifactResult result = getArtifactResolver()
+                        .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
+    {
+        JarFile jarFile = new JarFile( result.getArtifact().getFile() );
+        Enumeration entries = jarFile.entries();
+
+        while ( entries.hasMoreElements() )
+        {
+            JarEntry entry = (JarEntry) entries.nextElement();
+            String name = entry.getName();
+
+            // filter out files that do not end in .class
+            if ( !name.endsWith( ".class" ) )
+            {
+                continue;
+            }
+
+            // remove .class from the end and change format to use periods instead of forward slashes
+            name = name.substring( 0, name.length() - 6 ).replace( '/', '.' );
+            getLog().info( name );
+        }
+        jarFile.close();
+    }
+
+    private ProjectBuildingRequest buildBuildingRequest()

Review comment:
       fixed

##########
File path: src/main/java/org/apache/maven/plugins/dependency/ListClassesMojo.java
##########
@@ -0,0 +1,402 @@
+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. ie.
+     * 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 = buildBuildingRequest();
+        DefaultDependableCoordinate coordinate = getCoordinate();
+
+        try
+        {
+            if ( isTransitive() )
+            {
+                Iterable<ArtifactResult> artifacts = getDependencyResolver()
+                        .resolveDependencies( buildingRequest, coordinate, null );
+
+                for ( ArtifactResult result : artifacts )
+                {
+                    printClassesFromArtifactResult( result );
+                }
+            }
+            else
+            {
+                ArtifactResult result = getArtifactResolver()
+                        .resolveArtifact( buildingRequest, toArtifactCoordinate( coordinate ) );
+
+                printClassesFromArtifactResult( result );
+            }
+        }
+        catch ( ArtifactResolverException | DependencyResolverException | IOException e )
+        {
+            throw new MojoExecutionException( "Couldn't download artifact: " + e.getMessage(), e );

Review comment:
       fixed




----------------------------------------------------------------
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



[GitHub] [maven-dependency-plugin] elharo merged pull request #57: [MDEP-645] Created new mojo GetClassesMojo which lists all class dependencies for a specified artifact.

Posted by GitBox <gi...@apache.org>.
elharo merged pull request #57:
URL: https://github.com/apache/maven-dependency-plugin/pull/57


   


----------------------------------------------------------------
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



[GitHub] [maven-dependency-plugin] rmannibucau commented on a change in pull request #57: [MDEP-645] Created new mojo GetClassesMojo which lists all class dependencies for a specified artifact.

Posted by GitBox <gi...@apache.org>.
rmannibucau commented on a change in pull request #57:
URL: https://github.com/apache/maven-dependency-plugin/pull/57#discussion_r430520214



##########
File path: src/main/java/org/apache/maven/plugins/dependency/GetClassesMojo.java
##########
@@ -0,0 +1,396 @@
+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;
+import org.codehaus.plexus.util.StringUtils;
+
+@Mojo( name = "get-classes", requiresProject = false, threadSafe = true )
+public class GetClassesMojo
+    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 groupId of the artifact to download. Ignored if {@link #artifact} is used.
+     */
+    @Parameter( property = "groupId" )
+    private String groupId;
+
+    /**
+     * The artifactId 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 url, separated by comma. ie.
+     * 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 = "true" )
+    private boolean transitive = true;
+
+    /**
+     * Skip plugin execution completely.
+     *
+     * @since 2.7
+     */
+    @Parameter( property = "mdep.skip", defaultValue = "false" )
+    private boolean skip;
+
+    @Override
+    public void execute() throws MojoExecutionException, MojoFailureException
+    {
+        ProjectBuildingRequest buildingRequest = buildBuildingRequest();
+        DefaultDependableCoordinate coordinate = getCoordinate();
+
+        try
+        {
+            getLog().info( "Retrieving classes of dependencies for " + artifact );
+            if ( isTransitive() )
+            {
+                Iterable<ArtifactResult> artifacts = getDependencyResolver().resolveDependencies( buildingRequest, coordinate, null );
+
+                for ( ArtifactResult result : artifacts )
+                {
+                    printClassesFromArtifactResult( result );
+                }
+            }
+            else
+            {
+                ArtifactResult result = getArtifactResolver().resolveArtifact( buildingRequest, toArtifactCoordinate( coordinate ) );
+
+                printClassesFromArtifactResult( result );
+            }
+        }
+        catch ( ArtifactResolverException | DependencyResolverException | IOException e )
+        {
+            throw new MojoExecutionException( "Couldn't download artifact: " + e.getMessage(), e );
+        }
+    }
+
+    public void printClassesFromArtifactResult( ArtifactResult result )
+            throws IOException
+    {
+        JarFile jarFile = new JarFile( result.getArtifact().getFile() );
+        Enumeration e = jarFile.entries();
+
+        while ( e.hasMoreElements() )
+        {
+            JarEntry entry = ( JarEntry )e.nextElement();
+            String name = entry.getName();
+
+            // filter out files that do not end in .class
+            if ( name.length() <= 6 || !name.substring( name.length() - 6 ).equals( ".class" )) {
+                continue;
+            }
+
+            // remove .class from the end and change format to use periods instead of forward slashes
+            name = name.substring( 0, name.length() - 6 ).replace( '/', '.' );
+            getLog().info( name );

Review comment:
       +1, can be neat to be able to inject the list of classes in a maven project properties to reuse it downstream (exec-maven-plugin is my immediate thought but i'm sure there are more use cases). A dump in a file can be useful too.
   
   side note: what about multi release jars (META-INF/versions)? should it be filtered?

##########
File path: src/main/java/org/apache/maven/plugins/dependency/GetClassesMojo.java
##########
@@ -0,0 +1,396 @@
+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;
+import org.codehaus.plexus.util.StringUtils;
+
+@Mojo( name = "get-classes", requiresProject = false, threadSafe = true )
+public class GetClassesMojo
+    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 groupId of the artifact to download. Ignored if {@link #artifact} is used.
+     */
+    @Parameter( property = "groupId" )
+    private String groupId;
+
+    /**
+     * The artifactId 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 url, separated by comma. ie.
+     * 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 = "true" )
+    private boolean transitive = true;
+
+    /**
+     * Skip plugin execution completely.
+     *
+     * @since 2.7
+     */
+    @Parameter( property = "mdep.skip", defaultValue = "false" )

Review comment:
       @bimargulies-google I'd keep it since you never know how it is used and maven does not control that




----------------------------------------------------------------
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



[GitHub] [maven-dependency-plugin] jonvolfson commented on a change in pull request #57: [MDEP-645] Created new mojo GetClassesMojo which lists all class dependencies for a specified artifact.

Posted by GitBox <gi...@apache.org>.
jonvolfson commented on a change in pull request #57:
URL: https://github.com/apache/maven-dependency-plugin/pull/57#discussion_r431278088



##########
File path: src/main/java/org/apache/maven/plugins/dependency/ListClassesMojo.java
##########
@@ -0,0 +1,402 @@
+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. ie.
+     * 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 = buildBuildingRequest();
+        DefaultDependableCoordinate coordinate = getCoordinate();
+
+        try
+        {
+            if ( isTransitive() )
+            {
+                Iterable<ArtifactResult> artifacts = getDependencyResolver()

Review comment:
       fixed




----------------------------------------------------------------
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



[GitHub] [maven-dependency-plugin] jonvolfson commented on a change in pull request #57: [MDEP-645] Created new mojo GetClassesMojo which lists all class dependencies for a specified artifact.

Posted by GitBox <gi...@apache.org>.
jonvolfson commented on a change in pull request #57:
URL: https://github.com/apache/maven-dependency-plugin/pull/57#discussion_r441030053



##########
File path: src/main/java/org/apache/maven/plugins/dependency/GetClassesMojo.java
##########
@@ -0,0 +1,406 @@
+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;
+import org.codehaus.plexus.util.StringUtils;
+
+
+/**
+ * Retrieves and lists all class dependencies for the specified artifact from the specified remote repositories.
+ */
+@Mojo( name = "get-classes", requiresProject = false, threadSafe = true )
+public class GetClassesMojo
+    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 groupId of the artifact to download. Ignored if {@link #artifact} is used.
+     */
+    @Parameter( property = "groupId" )
+    private String groupId;
+
+    /**
+     * The artifactId 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 url, separated by comma. ie.
+     * 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 = "true" )
+    private boolean transitive = true;
+
+    /**
+     * Skip plugin execution completely.
+     *
+     * @since 2.7
+     */
+    @Parameter( property = "mdep.skip", defaultValue = "false" )
+    private boolean skip;
+
+    @Override
+    public void execute() throws MojoExecutionException, MojoFailureException
+    {
+        ProjectBuildingRequest buildingRequest = buildBuildingRequest();
+        DefaultDependableCoordinate coordinate = getCoordinate();
+
+        try
+        {
+            getLog().info( "Retrieving classes of dependencies for " + artifact );
+            if ( isTransitive() )
+            {
+                Iterable<ArtifactResult> artifacts = getDependencyResolver()
+                        .resolveDependencies( buildingRequest, coordinate, null );
+
+                for ( ArtifactResult result : artifacts )
+                {
+                    printClassesFromArtifactResult( result );
+                }
+            }
+            else
+            {
+                ArtifactResult result = getArtifactResolver()
+                        .resolveArtifact( buildingRequest, toArtifactCoordinate( coordinate ) );
+
+                printClassesFromArtifactResult( result );
+            }
+        }
+        catch ( ArtifactResolverException | DependencyResolverException | IOException e )
+        {
+            throw new MojoExecutionException( "Couldn't download artifact: " + e.getMessage(), e );
+        }
+    }
+
+    public void printClassesFromArtifactResult( ArtifactResult result )
+            throws IOException
+    {
+        JarFile jarFile = new JarFile( result.getArtifact().getFile() );
+        Enumeration e = jarFile.entries();
+
+        while ( e.hasMoreElements() )
+        {
+            JarEntry entry = (JarEntry) e.nextElement();
+            String name = entry.getName();
+
+            // filter out files that do not end in .class
+            if ( name.length() <= 6 || !name.substring( name.length() - 6 ).equals( ".class" ) )

Review comment:
       fixed, forgot to comment




----------------------------------------------------------------
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



[GitHub] [maven-dependency-plugin] elharo commented on a change in pull request #57: [MDEP-645] Created new mojo GetClassesMojo which lists all class dependencies for a specified artifact.

Posted by GitBox <gi...@apache.org>.
elharo commented on a change in pull request #57:
URL: https://github.com/apache/maven-dependency-plugin/pull/57#discussion_r431312447



##########
File path: src/test/java/org/apache/maven/plugins/dependency/TestGetClassesMojo.java
##########
@@ -0,0 +1,87 @@
+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 org.apache.maven.execution.MavenSession;
+import org.apache.maven.plugin.LegacySupport;
+import org.apache.maven.plugin.testing.stubs.MavenProjectStub;
+import org.apache.maven.settings.Server;
+import org.apache.maven.settings.Settings;
+import org.junit.Assert;
+import org.sonatype.aether.impl.internal.SimpleLocalRepositoryManager;
+import org.sonatype.aether.util.DefaultRepositorySystemSession;
+
+import java.io.File;
+
+public class TestGetClassesMojo
+        extends AbstractDependencyMojoTestCase
+{
+    ListClassesMojo mojo;

Review comment:
       make field private

##########
File path: src/main/java/org/apache/maven/plugins/dependency/ListClassesMojo.java
##########
@@ -0,0 +1,391 @@
+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 ( isTransitive() )
+            {
+                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 " + artifact + ": " + e.getMessage(), e );

Review comment:
       This message might not be quite accurate when you're downloading all transitive dependencies. That is, it could be one of the transitive deps we can't download instead of the original.

##########
File path: src/main/java/org/apache/maven/plugins/dependency/ListClassesMojo.java
##########
@@ -0,0 +1,391 @@
+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.
+     *

Review comment:
       nit: remove blank line

##########
File path: src/main/java/org/apache/maven/plugins/dependency/ListClassesMojo.java
##########
@@ -0,0 +1,391 @@
+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 ( isTransitive() )
+            {
+                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 " + artifact + ": " + e.getMessage(), e );
+        }
+    }
+
+    private void printClassesFromArtifactResult( ArtifactResult result )
+            throws IOException
+    {
+        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 );
+        }
+        jarFile.close();

Review comment:
       use try-with-resources to guarantee that this is closed when an exception is thrown

##########
File path: src/main/java/org/apache/maven/plugins/dependency/ListClassesMojo.java
##########
@@ -0,0 +1,391 @@
+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 ( isTransitive() )
+            {
+                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 " + artifact + ": " + e.getMessage(), e );
+        }
+    }
+
+    private void printClassesFromArtifactResult( ArtifactResult result )
+            throws IOException
+    {
+        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 );
+        }
+        jarFile.close();
+    }
+
+    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 )
+    {
+        ArtifactHandler artifactHandler = artifactHandlerManager.getArtifactHandler( dependableCoordinate.getType() );
+        DefaultArtifactCoordinate artifactCoordinate = new DefaultArtifactCoordinate();
+        artifactCoordinate.setGroupId( dependableCoordinate.getGroupId() );
+        artifactCoordinate.setArtifactId( dependableCoordinate.getArtifactId() );
+        artifactCoordinate.setVersion( dependableCoordinate.getVersion() );
+        artifactCoordinate.setClassifier( dependableCoordinate.getClassifier() );
+        artifactCoordinate.setExtension( artifactHandler.getExtension() );
+        return artifactCoordinate;
+    }
+
+    ArtifactRepository parseRepository( String repo, ArtifactRepositoryPolicy policy )
+            throws MojoFailureException
+    {
+        // if it's a simple url
+        String id = "temp";
+        ArtifactRepositoryLayout layout = getLayout( "default" );
+
+        // if it's an extended repo URL of the form id::layout::url
+        if ( repo.contains( "::" ) )
+        {
+            Matcher matcher = ALT_REPO_SYNTAX_PATTERN.matcher( repo );
+            if ( !matcher.matches() )
+            {
+                throw new MojoFailureException( repo, "Invalid syntax for repository: " + repo,
+                        "Invalid syntax for repository. Use \"id::layout::url\" or \"URL\"." );
+            }
+
+            id = matcher.group( 1 ).trim();
+            if ( !( matcher.group( 2 ) == null || matcher.group( 2 ).trim().isEmpty() ) )
+            {
+                layout = getLayout( matcher.group( 2 ).trim() );
+            }
+            repo = matcher.group( 3 ).trim();
+        }
+        return new MavenArtifactRepository( id, repo, layout, policy, policy );
+    }
+
+    private ArtifactRepositoryLayout getLayout( String id )
+            throws MojoFailureException
+    {
+        ArtifactRepositoryLayout layout = repositoryLayouts.get( id );
+
+        if ( layout == null )
+        {
+            throw new MojoFailureException( id, "Invalid repository layout", "Invalid repository layout: " + id );
+        }
+
+        return layout;
+    }
+
+    /**
+     * @return {@link #skip}

Review comment:
       I don't think you need these getter methods, and probably not the setters




----------------------------------------------------------------
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



[GitHub] [maven-dependency-plugin] jonvolfson commented on a change in pull request #57: [MDEP-645] Created new mojo GetClassesMojo which lists all class dependencies for a specified artifact.

Posted by GitBox <gi...@apache.org>.
jonvolfson commented on a change in pull request #57:
URL: https://github.com/apache/maven-dependency-plugin/pull/57#discussion_r441029465



##########
File path: src/main/java/org/apache/maven/plugins/dependency/GetClassesMojo.java
##########
@@ -0,0 +1,406 @@
+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;
+import org.codehaus.plexus.util.StringUtils;
+
+
+/**
+ * Retrieves and lists all class dependencies for the specified artifact from the specified remote repositories.
+ */
+@Mojo( name = "get-classes", requiresProject = false, threadSafe = true )
+public class GetClassesMojo
+    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 groupId of the artifact to download. Ignored if {@link #artifact} is used.
+     */
+    @Parameter( property = "groupId" )
+    private String groupId;
+
+    /**
+     * The artifactId 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 url, separated by comma. ie.
+     * 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 = "true" )
+    private boolean transitive = true;
+
+    /**
+     * Skip plugin execution completely.
+     *
+     * @since 2.7

Review comment:
       fixed, forgot to comment




----------------------------------------------------------------
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



[GitHub] [maven-dependency-plugin] elharo commented on a change in pull request #57: [MDEP-645] Created new mojo GetClassesMojo which lists all class dependencies for a specified artifact.

Posted by GitBox <gi...@apache.org>.
elharo commented on a change in pull request #57:
URL: https://github.com/apache/maven-dependency-plugin/pull/57#discussion_r430534915



##########
File path: src/main/java/org/apache/maven/plugins/dependency/GetClassesMojo.java
##########
@@ -0,0 +1,406 @@
+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;
+import org.codehaus.plexus.util.StringUtils;
+
+
+/**
+ * Retrieves and lists all class dependencies for the specified artifact from the specified remote repositories.

Review comment:
       class dependencies for --> "classes contained in" as these are not dependencies

##########
File path: src/main/java/org/apache/maven/plugins/dependency/GetClassesMojo.java
##########
@@ -0,0 +1,406 @@
+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;
+import org.codehaus.plexus.util.StringUtils;
+
+
+/**
+ * Retrieves and lists all class dependencies for the specified artifact from the specified remote repositories.
+ */
+@Mojo( name = "get-classes", requiresProject = false, threadSafe = true )
+public class GetClassesMojo

Review comment:
       Perhaps ListClassesMojo?

##########
File path: src/main/java/org/apache/maven/plugins/dependency/GetClassesMojo.java
##########
@@ -0,0 +1,406 @@
+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;
+import org.codehaus.plexus.util.StringUtils;
+
+
+/**
+ * Retrieves and lists all class dependencies for the specified artifact from the specified remote repositories.
+ */
+@Mojo( name = "get-classes", requiresProject = false, threadSafe = true )
+public class GetClassesMojo
+    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 groupId of the artifact to download. Ignored if {@link #artifact} is used.
+     */
+    @Parameter( property = "groupId" )
+    private String groupId;
+
+    /**
+     * The artifactId 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 url, separated by comma. ie.
+     * 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 = "true" )
+    private boolean transitive = true;
+
+    /**
+     * Skip plugin execution completely.
+     *
+     * @since 2.7
+     */
+    @Parameter( property = "mdep.skip", defaultValue = "false" )
+    private boolean skip;
+
+    @Override
+    public void execute() throws MojoExecutionException, MojoFailureException
+    {
+        ProjectBuildingRequest buildingRequest = buildBuildingRequest();
+        DefaultDependableCoordinate coordinate = getCoordinate();
+
+        try
+        {
+            getLog().info( "Retrieving classes of dependencies for " + artifact );
+            if ( isTransitive() )
+            {
+                Iterable<ArtifactResult> artifacts = getDependencyResolver()
+                        .resolveDependencies( buildingRequest, coordinate, null );
+
+                for ( ArtifactResult result : artifacts )
+                {
+                    printClassesFromArtifactResult( result );
+                }
+            }
+            else
+            {
+                ArtifactResult result = getArtifactResolver()
+                        .resolveArtifact( buildingRequest, toArtifactCoordinate( coordinate ) );
+
+                printClassesFromArtifactResult( result );
+            }
+        }
+        catch ( ArtifactResolverException | DependencyResolverException | IOException e )
+        {
+            throw new MojoExecutionException( "Couldn't download artifact: " + e.getMessage(), e );
+        }
+    }
+
+    public void printClassesFromArtifactResult( ArtifactResult result )
+            throws IOException
+    {
+        JarFile jarFile = new JarFile( result.getArtifact().getFile() );
+        Enumeration e = jarFile.entries();
+
+        while ( e.hasMoreElements() )
+        {
+            JarEntry entry = (JarEntry) e.nextElement();
+            String name = entry.getName();
+
+            // filter out files that do not end in .class
+            if ( name.length() <= 6 || !name.substring( name.length() - 6 ).equals( ".class" ) )

Review comment:
       name.endsWith(".class")

##########
File path: src/main/java/org/apache/maven/plugins/dependency/GetClassesMojo.java
##########
@@ -0,0 +1,406 @@
+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;
+import org.codehaus.plexus.util.StringUtils;
+
+
+/**
+ * Retrieves and lists all class dependencies for the specified artifact from the specified remote repositories.
+ */
+@Mojo( name = "get-classes", requiresProject = false, threadSafe = true )
+public class GetClassesMojo
+    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 groupId of the artifact to download. Ignored if {@link #artifact} is used.

Review comment:
       group ID

##########
File path: src/main/java/org/apache/maven/plugins/dependency/GetClassesMojo.java
##########
@@ -0,0 +1,406 @@
+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;
+import org.codehaus.plexus.util.StringUtils;
+
+
+/**
+ * Retrieves and lists all class dependencies for the specified artifact from the specified remote repositories.
+ */
+@Mojo( name = "get-classes", requiresProject = false, threadSafe = true )
+public class GetClassesMojo
+    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 groupId of the artifact to download. Ignored if {@link #artifact} is used.
+     */
+    @Parameter( property = "groupId" )
+    private String groupId;
+
+    /**
+     * The artifactId 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";

Review comment:
       will this work for anything that's not a jar?

##########
File path: src/test/java/org/apache/maven/plugins/dependency/TestGetClassesMojo.java
##########
@@ -0,0 +1,86 @@
+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 org.apache.maven.execution.MavenSession;
+import org.apache.maven.plugin.LegacySupport;
+import org.apache.maven.plugin.testing.stubs.MavenProjectStub;
+import org.apache.maven.settings.Server;
+import org.apache.maven.settings.Settings;
+import org.sonatype.aether.impl.internal.SimpleLocalRepositoryManager;
+import org.sonatype.aether.util.DefaultRepositorySystemSession;
+
+import java.io.File;
+
+public class TestGetClassesMojo
+        extends AbstractDependencyMojoTestCase
+{
+    GetClassesMojo mojo;

Review comment:
       private

##########
File path: src/main/java/org/apache/maven/plugins/dependency/GetClassesMojo.java
##########
@@ -0,0 +1,406 @@
+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;
+import org.codehaus.plexus.util.StringUtils;
+
+
+/**
+ * Retrieves and lists all class dependencies for the specified artifact from the specified remote repositories.
+ */
+@Mojo( name = "get-classes", requiresProject = false, threadSafe = true )
+public class GetClassesMojo
+    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 groupId of the artifact to download. Ignored if {@link #artifact} is used.
+     */
+    @Parameter( property = "groupId" )
+    private String groupId;
+
+    /**
+     * The artifactId 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 url, separated by comma. ie.
+     * 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 = "true" )
+    private boolean transitive = true;
+
+    /**
+     * Skip plugin execution completely.
+     *
+     * @since 2.7

Review comment:
       `@since` doesn't make sense here

##########
File path: src/main/java/org/apache/maven/plugins/dependency/GetClassesMojo.java
##########
@@ -0,0 +1,406 @@
+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;
+import org.codehaus.plexus.util.StringUtils;
+
+
+/**
+ * Retrieves and lists all class dependencies for the specified artifact from the specified remote repositories.
+ */
+@Mojo( name = "get-classes", requiresProject = false, threadSafe = true )
+public class GetClassesMojo
+    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 groupId of the artifact to download. Ignored if {@link #artifact} is used.
+     */
+    @Parameter( property = "groupId" )
+    private String groupId;
+
+    /**
+     * The artifactId 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 url, separated by comma. ie.
+     * 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 = "true" )
+    private boolean transitive = true;
+
+    /**
+     * Skip plugin execution completely.
+     *
+     * @since 2.7
+     */
+    @Parameter( property = "mdep.skip", defaultValue = "false" )
+    private boolean skip;
+
+    @Override
+    public void execute() throws MojoExecutionException, MojoFailureException
+    {
+        ProjectBuildingRequest buildingRequest = buildBuildingRequest();
+        DefaultDependableCoordinate coordinate = getCoordinate();
+
+        try
+        {
+            getLog().info( "Retrieving classes of dependencies for " + artifact );

Review comment:
       Not a helpful log message. In general we have way too much logging. Only log things the end user actually wants to see.

##########
File path: src/main/java/org/apache/maven/plugins/dependency/GetClassesMojo.java
##########
@@ -0,0 +1,406 @@
+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;
+import org.codehaus.plexus.util.StringUtils;
+
+
+/**
+ * Retrieves and lists all class dependencies for the specified artifact from the specified remote repositories.
+ */
+@Mojo( name = "get-classes", requiresProject = false, threadSafe = true )
+public class GetClassesMojo
+    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 groupId of the artifact to download. Ignored if {@link #artifact} is used.
+     */
+    @Parameter( property = "groupId" )
+    private String groupId;
+
+    /**
+     * The artifactId 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 url, separated by comma. ie.
+     * 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 = "true" )
+    private boolean transitive = true;
+
+    /**
+     * Skip plugin execution completely.
+     *
+     * @since 2.7
+     */
+    @Parameter( property = "mdep.skip", defaultValue = "false" )
+    private boolean skip;
+
+    @Override
+    public void execute() throws MojoExecutionException, MojoFailureException
+    {
+        ProjectBuildingRequest buildingRequest = buildBuildingRequest();
+        DefaultDependableCoordinate coordinate = getCoordinate();
+
+        try
+        {
+            getLog().info( "Retrieving classes of dependencies for " + artifact );
+            if ( isTransitive() )
+            {
+                Iterable<ArtifactResult> artifacts = getDependencyResolver()
+                        .resolveDependencies( buildingRequest, coordinate, null );
+
+                for ( ArtifactResult result : artifacts )
+                {
+                    printClassesFromArtifactResult( result );
+                }
+            }
+            else
+            {
+                ArtifactResult result = getArtifactResolver()
+                        .resolveArtifact( buildingRequest, toArtifactCoordinate( coordinate ) );
+
+                printClassesFromArtifactResult( result );
+            }
+        }
+        catch ( ArtifactResolverException | DependencyResolverException | IOException e )
+        {
+            throw new MojoExecutionException( "Couldn't download artifact: " + e.getMessage(), e );
+        }
+    }
+
+    public void printClassesFromArtifactResult( ArtifactResult result )

Review comment:
       why is this public? Methods should have the most restrictive access possible.

##########
File path: src/test/java/org/apache/maven/plugins/dependency/TestGetClassesMojo.java
##########
@@ -0,0 +1,86 @@
+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 org.apache.maven.execution.MavenSession;
+import org.apache.maven.plugin.LegacySupport;
+import org.apache.maven.plugin.testing.stubs.MavenProjectStub;
+import org.apache.maven.settings.Server;
+import org.apache.maven.settings.Settings;
+import org.sonatype.aether.impl.internal.SimpleLocalRepositoryManager;
+import org.sonatype.aether.util.DefaultRepositorySystemSession;
+
+import java.io.File;
+
+public class TestGetClassesMojo
+        extends AbstractDependencyMojoTestCase
+{
+    GetClassesMojo mojo;
+
+    protected void setUp()
+            throws Exception
+    {
+        // required for mojo lookups to work
+        super.setUp( "markers", false );
+
+        File testPom = new File( getBasedir(), "target/test-classes/unit/get-test/plugin-config.xml" );
+        assert testPom.exists();

Review comment:
       NEVER use assert

##########
File path: src/main/java/org/apache/maven/plugins/dependency/GetClassesMojo.java
##########
@@ -0,0 +1,406 @@
+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;
+import org.codehaus.plexus.util.StringUtils;
+
+
+/**
+ * Retrieves and lists all class dependencies for the specified artifact from the specified remote repositories.
+ */
+@Mojo( name = "get-classes", requiresProject = false, threadSafe = true )
+public class GetClassesMojo
+    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 groupId of the artifact to download. Ignored if {@link #artifact} is used.
+     */
+    @Parameter( property = "groupId" )
+    private String groupId;
+
+    /**
+     * The artifactId 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 url, separated by comma. ie.
+     * 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 = "true" )
+    private boolean transitive = true;
+
+    /**
+     * Skip plugin execution completely.
+     *
+     * @since 2.7
+     */
+    @Parameter( property = "mdep.skip", defaultValue = "false" )
+    private boolean skip;
+
+    @Override
+    public void execute() throws MojoExecutionException, MojoFailureException
+    {
+        ProjectBuildingRequest buildingRequest = buildBuildingRequest();
+        DefaultDependableCoordinate coordinate = getCoordinate();
+
+        try
+        {
+            getLog().info( "Retrieving classes of dependencies for " + artifact );
+            if ( isTransitive() )
+            {
+                Iterable<ArtifactResult> artifacts = getDependencyResolver()
+                        .resolveDependencies( buildingRequest, coordinate, null );
+
+                for ( ArtifactResult result : artifacts )
+                {
+                    printClassesFromArtifactResult( result );
+                }
+            }
+            else
+            {
+                ArtifactResult result = getArtifactResolver()
+                        .resolveArtifact( buildingRequest, toArtifactCoordinate( coordinate ) );
+
+                printClassesFromArtifactResult( result );
+            }
+        }
+        catch ( ArtifactResolverException | DependencyResolverException | IOException e )
+        {
+            throw new MojoExecutionException( "Couldn't download artifact: " + e.getMessage(), e );
+        }
+    }
+
+    public void printClassesFromArtifactResult( ArtifactResult result )
+            throws IOException
+    {
+        JarFile jarFile = new JarFile( result.getArtifact().getFile() );
+        Enumeration e = jarFile.entries();
+
+        while ( e.hasMoreElements() )
+        {
+            JarEntry entry = (JarEntry) e.nextElement();
+            String name = entry.getName();
+
+            // filter out files that do not end in .class
+            if ( name.length() <= 6 || !name.substring( name.length() - 6 ).equals( ".class" ) )
+            {
+                continue;
+            }
+
+            // remove .class from the end and change format to use periods instead of forward slashes
+            name = name.substring( 0, name.length() - 6 ).replace( '/', '.' );
+            getLog().info( name );
+        }
+        jarFile.close();
+    }
+
+    public ProjectBuildingRequest buildBuildingRequest()
+            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 = StringUtils.split( artifact, ":" );
+            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 = StringUtils.split( remoteRepositories, "," );
+            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 )
+    {
+        ArtifactHandler artifactHandler = artifactHandlerManager.getArtifactHandler( dependableCoordinate.getType() );
+        DefaultArtifactCoordinate artifactCoordinate = new DefaultArtifactCoordinate();
+        artifactCoordinate.setGroupId( dependableCoordinate.getGroupId() );
+        artifactCoordinate.setArtifactId( dependableCoordinate.getArtifactId() );
+        artifactCoordinate.setVersion( dependableCoordinate.getVersion() );
+        artifactCoordinate.setClassifier( dependableCoordinate.getClassifier() );
+        artifactCoordinate.setExtension( artifactHandler.getExtension() );
+        return artifactCoordinate;
+    }
+
+    ArtifactRepository parseRepository( String repo, ArtifactRepositoryPolicy policy )
+            throws MojoFailureException
+    {
+        // if it's a simple url
+        String id = "temp";
+        ArtifactRepositoryLayout layout = getLayout( "default" );
+        String url = repo;
+
+        // if it's an extended repo URL of the form id::layout::url
+        if ( repo.contains( "::" ) )
+        {
+            Matcher matcher = ALT_REPO_SYNTAX_PATTERN.matcher( repo );
+            if ( !matcher.matches() )
+            {
+                throw new MojoFailureException( repo, "Invalid syntax for repository: " + repo,
+                        "Invalid syntax for repository. Use \"id::layout::url\" or \"URL\"." );
+            }
+
+            id = matcher.group( 1 ).trim();
+            if ( !StringUtils.isEmpty( matcher.group( 2 ) ) )
+            {
+                layout = getLayout( matcher.group( 2 ).trim() );
+            }
+            url = matcher.group( 3 ).trim();
+        }
+        return new MavenArtifactRepository( id, url, layout, policy, policy );
+    }
+
+    private ArtifactRepositoryLayout getLayout( String id )
+            throws MojoFailureException
+    {
+        ArtifactRepositoryLayout layout = repositoryLayouts.get( id );
+
+        if ( layout == null )
+        {
+            throw new MojoFailureException( id, "Invalid repository layout", "Invalid repository layout: " + id );
+        }
+
+        return layout;
+    }
+
+    /**
+     * @return {@link #skip}
+     */
+    protected boolean isSkip()
+    {
+        return skip;
+    }
+
+    protected boolean isTransitive()
+    {
+        return transitive;
+    }
+
+    protected DefaultDependableCoordinate getCoordinate()
+    {
+        return coordinate;
+    }
+
+    protected DependencyResolver getDependencyResolver()
+    {
+        return dependencyResolver;
+    }
+
+    protected ArtifactResolver getArtifactResolver()
+    {
+        return artifactResolver;
+    }
+
+    /**
+     * @param artifact The artifact
+     */
+    public void setArtifact( String artifact )
+    {
+        this.artifact = artifact;
+    }
+
+    /**
+     * @param groupId The groupId.
+     */
+    public void setGroupId( String groupId )
+    {
+        this.coordinate.setGroupId( groupId );
+    }
+
+    /**
+     * @param artifactId The artifactId.

Review comment:
       artifact ID

##########
File path: src/main/java/org/apache/maven/plugins/dependency/GetClassesMojo.java
##########
@@ -0,0 +1,406 @@
+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;
+import org.codehaus.plexus.util.StringUtils;
+
+
+/**
+ * Retrieves and lists all class dependencies for the specified artifact from the specified remote repositories.
+ */
+@Mojo( name = "get-classes", requiresProject = false, threadSafe = true )
+public class GetClassesMojo
+    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 groupId of the artifact to download. Ignored if {@link #artifact} is used.
+     */
+    @Parameter( property = "groupId" )
+    private String groupId;
+
+    /**
+     * The artifactId 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 url, separated by comma. ie.
+     * 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 = "true" )
+    private boolean transitive = true;
+
+    /**
+     * Skip plugin execution completely.
+     *
+     * @since 2.7
+     */
+    @Parameter( property = "mdep.skip", defaultValue = "false" )
+    private boolean skip;
+
+    @Override
+    public void execute() throws MojoExecutionException, MojoFailureException
+    {
+        ProjectBuildingRequest buildingRequest = buildBuildingRequest();
+        DefaultDependableCoordinate coordinate = getCoordinate();
+
+        try
+        {
+            getLog().info( "Retrieving classes of dependencies for " + artifact );
+            if ( isTransitive() )
+            {
+                Iterable<ArtifactResult> artifacts = getDependencyResolver()
+                        .resolveDependencies( buildingRequest, coordinate, null );
+
+                for ( ArtifactResult result : artifacts )
+                {
+                    printClassesFromArtifactResult( result );
+                }
+            }
+            else
+            {
+                ArtifactResult result = getArtifactResolver()
+                        .resolveArtifact( buildingRequest, toArtifactCoordinate( coordinate ) );
+
+                printClassesFromArtifactResult( result );
+            }
+        }
+        catch ( ArtifactResolverException | DependencyResolverException | IOException e )
+        {
+            throw new MojoExecutionException( "Couldn't download artifact: " + e.getMessage(), e );
+        }
+    }
+
+    public void printClassesFromArtifactResult( ArtifactResult result )
+            throws IOException
+    {
+        JarFile jarFile = new JarFile( result.getArtifact().getFile() );
+        Enumeration e = jarFile.entries();
+
+        while ( e.hasMoreElements() )
+        {
+            JarEntry entry = (JarEntry) e.nextElement();
+            String name = entry.getName();
+
+            // filter out files that do not end in .class
+            if ( name.length() <= 6 || !name.substring( name.length() - 6 ).equals( ".class" ) )
+            {
+                continue;
+            }
+
+            // remove .class from the end and change format to use periods instead of forward slashes
+            name = name.substring( 0, name.length() - 6 ).replace( '/', '.' );
+            getLog().info( name );
+        }
+        jarFile.close();
+    }
+
+    public ProjectBuildingRequest buildBuildingRequest()
+            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 = StringUtils.split( artifact, ":" );
+            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 = StringUtils.split( remoteRepositories, "," );
+            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 )
+    {
+        ArtifactHandler artifactHandler = artifactHandlerManager.getArtifactHandler( dependableCoordinate.getType() );
+        DefaultArtifactCoordinate artifactCoordinate = new DefaultArtifactCoordinate();
+        artifactCoordinate.setGroupId( dependableCoordinate.getGroupId() );
+        artifactCoordinate.setArtifactId( dependableCoordinate.getArtifactId() );
+        artifactCoordinate.setVersion( dependableCoordinate.getVersion() );
+        artifactCoordinate.setClassifier( dependableCoordinate.getClassifier() );
+        artifactCoordinate.setExtension( artifactHandler.getExtension() );
+        return artifactCoordinate;
+    }
+
+    ArtifactRepository parseRepository( String repo, ArtifactRepositoryPolicy policy )
+            throws MojoFailureException
+    {
+        // if it's a simple url
+        String id = "temp";
+        ArtifactRepositoryLayout layout = getLayout( "default" );
+        String url = repo;
+
+        // if it's an extended repo URL of the form id::layout::url
+        if ( repo.contains( "::" ) )
+        {
+            Matcher matcher = ALT_REPO_SYNTAX_PATTERN.matcher( repo );
+            if ( !matcher.matches() )
+            {
+                throw new MojoFailureException( repo, "Invalid syntax for repository: " + repo,
+                        "Invalid syntax for repository. Use \"id::layout::url\" or \"URL\"." );
+            }
+
+            id = matcher.group( 1 ).trim();
+            if ( !StringUtils.isEmpty( matcher.group( 2 ) ) )
+            {
+                layout = getLayout( matcher.group( 2 ).trim() );
+            }
+            url = matcher.group( 3 ).trim();
+        }
+        return new MavenArtifactRepository( id, url, layout, policy, policy );
+    }
+
+    private ArtifactRepositoryLayout getLayout( String id )
+            throws MojoFailureException
+    {
+        ArtifactRepositoryLayout layout = repositoryLayouts.get( id );
+
+        if ( layout == null )
+        {
+            throw new MojoFailureException( id, "Invalid repository layout", "Invalid repository layout: " + id );
+        }
+
+        return layout;
+    }
+
+    /**
+     * @return {@link #skip}
+     */
+    protected boolean isSkip()
+    {
+        return skip;
+    }
+
+    protected boolean isTransitive()
+    {
+        return transitive;
+    }
+
+    protected DefaultDependableCoordinate getCoordinate()
+    {
+        return coordinate;
+    }
+
+    protected DependencyResolver getDependencyResolver()
+    {
+        return dependencyResolver;
+    }
+
+    protected ArtifactResolver getArtifactResolver()
+    {
+        return artifactResolver;
+    }
+
+    /**
+     * @param artifact The artifact

Review comment:
       doc comments begin with lower case, per Oracle guidelines

##########
File path: src/main/java/org/apache/maven/plugins/dependency/GetClassesMojo.java
##########
@@ -0,0 +1,396 @@
+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;
+import org.codehaus.plexus.util.StringUtils;
+
+@Mojo( name = "get-classes", requiresProject = false, threadSafe = true )
+public class GetClassesMojo
+    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 groupId of the artifact to download. Ignored if {@link #artifact} is used.
+     */
+    @Parameter( property = "groupId" )
+    private String groupId;
+
+    /**
+     * The artifactId 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 url, separated by comma. ie.
+     * 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 = "true" )
+    private boolean transitive = true;
+
+    /**
+     * Skip plugin execution completely.
+     *
+     * @since 2.7
+     */
+    @Parameter( property = "mdep.skip", defaultValue = "false" )
+    private boolean skip;
+
+    @Override
+    public void execute() throws MojoExecutionException, MojoFailureException
+    {
+        ProjectBuildingRequest buildingRequest = buildBuildingRequest();
+        DefaultDependableCoordinate coordinate = getCoordinate();
+
+        try
+        {
+            getLog().info( "Retrieving classes of dependencies for " + artifact );
+            if ( isTransitive() )
+            {
+                Iterable<ArtifactResult> artifacts = getDependencyResolver().resolveDependencies( buildingRequest, coordinate, null );
+
+                for ( ArtifactResult result : artifacts )
+                {
+                    printClassesFromArtifactResult( result );
+                }
+            }
+            else
+            {
+                ArtifactResult result = getArtifactResolver().resolveArtifact( buildingRequest, toArtifactCoordinate( coordinate ) );
+
+                printClassesFromArtifactResult( result );
+            }
+        }
+        catch ( ArtifactResolverException | DependencyResolverException | IOException e )
+        {
+            throw new MojoExecutionException( "Couldn't download artifact: " + e.getMessage(), e );
+        }
+    }
+
+    public void printClassesFromArtifactResult( ArtifactResult result )
+            throws IOException
+    {
+        JarFile jarFile = new JarFile( result.getArtifact().getFile() );
+        Enumeration e = jarFile.entries();
+
+        while ( e.hasMoreElements() )
+        {
+            JarEntry entry = ( JarEntry )e.nextElement();
+            String name = entry.getName();
+
+            // filter out files that do not end in .class
+            if ( name.length() <= 6 || !name.substring( name.length() - 6 ).equals( ".class" )) {
+                continue;
+            }
+
+            // remove .class from the end and change format to use periods instead of forward slashes
+            name = name.substring( 0, name.length() - 6 ).replace( '/', '.' );
+            getLog().info( name );

Review comment:
       I think logging is how we usually do this. The log can be injected or tested.

##########
File path: src/test/java/org/apache/maven/plugins/dependency/TestGetClassesMojo.java
##########
@@ -0,0 +1,86 @@
+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 org.apache.maven.execution.MavenSession;
+import org.apache.maven.plugin.LegacySupport;
+import org.apache.maven.plugin.testing.stubs.MavenProjectStub;
+import org.apache.maven.settings.Server;
+import org.apache.maven.settings.Settings;
+import org.sonatype.aether.impl.internal.SimpleLocalRepositoryManager;

Review comment:
       Tricky but can we replace this with org.eclipse equivalents? Probably not a 1:1 replacement. 

##########
File path: src/main/java/org/apache/maven/plugins/dependency/GetClassesMojo.java
##########
@@ -0,0 +1,406 @@
+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;
+import org.codehaus.plexus.util.StringUtils;
+
+
+/**
+ * Retrieves and lists all class dependencies for the specified artifact from the specified remote repositories.
+ */
+@Mojo( name = "get-classes", requiresProject = false, threadSafe = true )
+public class GetClassesMojo
+    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 groupId of the artifact to download. Ignored if {@link #artifact} is used.
+     */
+    @Parameter( property = "groupId" )
+    private String groupId;
+
+    /**
+     * The artifactId 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 url, separated by comma. ie.
+     * 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 = "true" )
+    private boolean transitive = true;
+
+    /**
+     * Skip plugin execution completely.
+     *
+     * @since 2.7
+     */
+    @Parameter( property = "mdep.skip", defaultValue = "false" )
+    private boolean skip;
+
+    @Override
+    public void execute() throws MojoExecutionException, MojoFailureException
+    {
+        ProjectBuildingRequest buildingRequest = buildBuildingRequest();
+        DefaultDependableCoordinate coordinate = getCoordinate();
+
+        try
+        {
+            getLog().info( "Retrieving classes of dependencies for " + artifact );
+            if ( isTransitive() )
+            {
+                Iterable<ArtifactResult> artifacts = getDependencyResolver()
+                        .resolveDependencies( buildingRequest, coordinate, null );
+
+                for ( ArtifactResult result : artifacts )
+                {
+                    printClassesFromArtifactResult( result );
+                }
+            }
+            else
+            {
+                ArtifactResult result = getArtifactResolver()
+                        .resolveArtifact( buildingRequest, toArtifactCoordinate( coordinate ) );
+
+                printClassesFromArtifactResult( result );
+            }
+        }
+        catch ( ArtifactResolverException | DependencyResolverException | IOException e )
+        {
+            throw new MojoExecutionException( "Couldn't download artifact: " + e.getMessage(), e );
+        }
+    }
+
+    public void printClassesFromArtifactResult( ArtifactResult result )
+            throws IOException
+    {
+        JarFile jarFile = new JarFile( result.getArtifact().getFile() );
+        Enumeration e = jarFile.entries();

Review comment:
       e --> entries 
   
   In general, avoid single letter variable names except for loop counters

##########
File path: src/main/java/org/apache/maven/plugins/dependency/GetClassesMojo.java
##########
@@ -0,0 +1,406 @@
+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;
+import org.codehaus.plexus.util.StringUtils;
+
+
+/**
+ * Retrieves and lists all class dependencies for the specified artifact from the specified remote repositories.
+ */
+@Mojo( name = "get-classes", requiresProject = false, threadSafe = true )
+public class GetClassesMojo
+    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 groupId of the artifact to download. Ignored if {@link #artifact} is used.
+     */
+    @Parameter( property = "groupId" )
+    private String groupId;
+
+    /**
+     * The artifactId 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 url, separated by comma. ie.
+     * 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.

Review comment:
       I don't think this should follow transitive dependencies

##########
File path: src/main/java/org/apache/maven/plugins/dependency/GetClassesMojo.java
##########
@@ -0,0 +1,406 @@
+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;
+import org.codehaus.plexus.util.StringUtils;
+
+
+/**
+ * Retrieves and lists all class dependencies for the specified artifact from the specified remote repositories.
+ */
+@Mojo( name = "get-classes", requiresProject = false, threadSafe = true )
+public class GetClassesMojo
+    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 groupId of the artifact to download. Ignored if {@link #artifact} is used.
+     */
+    @Parameter( property = "groupId" )
+    private String groupId;
+
+    /**
+     * The artifactId 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 url, separated by comma. ie.

Review comment:
       url, --> URLs,

##########
File path: src/main/java/org/apache/maven/plugins/dependency/GetClassesMojo.java
##########
@@ -0,0 +1,406 @@
+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;
+import org.codehaus.plexus.util.StringUtils;

Review comment:
       please don't use this class any more. apache commons stringutils if you must. 

##########
File path: src/main/java/org/apache/maven/plugins/dependency/GetClassesMojo.java
##########
@@ -0,0 +1,406 @@
+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;
+import org.codehaus.plexus.util.StringUtils;
+
+
+/**
+ * Retrieves and lists all class dependencies for the specified artifact from the specified remote repositories.
+ */
+@Mojo( name = "get-classes", requiresProject = false, threadSafe = true )
+public class GetClassesMojo
+    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 groupId of the artifact to download. Ignored if {@link #artifact} is used.
+     */
+    @Parameter( property = "groupId" )
+    private String groupId;
+
+    /**
+     * The artifactId of the artifact to download. Ignored if {@link #artifact} is used.

Review comment:
       artifact ID

##########
File path: src/main/java/org/apache/maven/plugins/dependency/GetClassesMojo.java
##########
@@ -0,0 +1,406 @@
+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;
+import org.codehaus.plexus.util.StringUtils;
+
+
+/**
+ * Retrieves and lists all class dependencies for the specified artifact from the specified remote repositories.
+ */
+@Mojo( name = "get-classes", requiresProject = false, threadSafe = true )
+public class GetClassesMojo
+    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 groupId of the artifact to download. Ignored if {@link #artifact} is used.
+     */
+    @Parameter( property = "groupId" )
+    private String groupId;
+
+    /**
+     * The artifactId 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 url, separated by comma. ie.
+     * 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 = "true" )
+    private boolean transitive = true;
+
+    /**
+     * Skip plugin execution completely.
+     *
+     * @since 2.7
+     */
+    @Parameter( property = "mdep.skip", defaultValue = "false" )
+    private boolean skip;
+
+    @Override
+    public void execute() throws MojoExecutionException, MojoFailureException
+    {
+        ProjectBuildingRequest buildingRequest = buildBuildingRequest();
+        DefaultDependableCoordinate coordinate = getCoordinate();
+
+        try
+        {
+            getLog().info( "Retrieving classes of dependencies for " + artifact );
+            if ( isTransitive() )
+            {
+                Iterable<ArtifactResult> artifacts = getDependencyResolver()
+                        .resolveDependencies( buildingRequest, coordinate, null );
+
+                for ( ArtifactResult result : artifacts )
+                {
+                    printClassesFromArtifactResult( result );
+                }
+            }
+            else
+            {
+                ArtifactResult result = getArtifactResolver()
+                        .resolveArtifact( buildingRequest, toArtifactCoordinate( coordinate ) );
+
+                printClassesFromArtifactResult( result );
+            }
+        }
+        catch ( ArtifactResolverException | DependencyResolverException | IOException e )
+        {
+            throw new MojoExecutionException( "Couldn't download artifact: " + e.getMessage(), e );
+        }
+    }
+
+    public void printClassesFromArtifactResult( ArtifactResult result )
+            throws IOException
+    {
+        JarFile jarFile = new JarFile( result.getArtifact().getFile() );
+        Enumeration e = jarFile.entries();
+
+        while ( e.hasMoreElements() )
+        {
+            JarEntry entry = (JarEntry) e.nextElement();
+            String name = entry.getName();
+
+            // filter out files that do not end in .class
+            if ( name.length() <= 6 || !name.substring( name.length() - 6 ).equals( ".class" ) )
+            {
+                continue;
+            }
+
+            // remove .class from the end and change format to use periods instead of forward slashes
+            name = name.substring( 0, name.length() - 6 ).replace( '/', '.' );
+            getLog().info( name );
+        }
+        jarFile.close();
+    }
+
+    public ProjectBuildingRequest buildBuildingRequest()

Review comment:
       why is this public? Methods should have the most restrictive access possible.

##########
File path: src/main/java/org/apache/maven/plugins/dependency/GetClassesMojo.java
##########
@@ -0,0 +1,406 @@
+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;
+import org.codehaus.plexus.util.StringUtils;
+
+
+/**
+ * Retrieves and lists all class dependencies for the specified artifact from the specified remote repositories.
+ */
+@Mojo( name = "get-classes", requiresProject = false, threadSafe = true )
+public class GetClassesMojo
+    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 groupId of the artifact to download. Ignored if {@link #artifact} is used.
+     */
+    @Parameter( property = "groupId" )
+    private String groupId;
+
+    /**
+     * The artifactId 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 url, separated by comma. ie.
+     * 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 = "true" )
+    private boolean transitive = true;
+
+    /**
+     * Skip plugin execution completely.
+     *
+     * @since 2.7
+     */
+    @Parameter( property = "mdep.skip", defaultValue = "false" )
+    private boolean skip;
+
+    @Override
+    public void execute() throws MojoExecutionException, MojoFailureException
+    {
+        ProjectBuildingRequest buildingRequest = buildBuildingRequest();
+        DefaultDependableCoordinate coordinate = getCoordinate();
+
+        try
+        {
+            getLog().info( "Retrieving classes of dependencies for " + artifact );
+            if ( isTransitive() )
+            {
+                Iterable<ArtifactResult> artifacts = getDependencyResolver()
+                        .resolveDependencies( buildingRequest, coordinate, null );
+
+                for ( ArtifactResult result : artifacts )
+                {
+                    printClassesFromArtifactResult( result );
+                }
+            }
+            else
+            {
+                ArtifactResult result = getArtifactResolver()
+                        .resolveArtifact( buildingRequest, toArtifactCoordinate( coordinate ) );
+
+                printClassesFromArtifactResult( result );
+            }
+        }
+        catch ( ArtifactResolverException | DependencyResolverException | IOException e )
+        {
+            throw new MojoExecutionException( "Couldn't download artifact: " + e.getMessage(), e );
+        }
+    }
+
+    public void printClassesFromArtifactResult( ArtifactResult result )
+            throws IOException
+    {
+        JarFile jarFile = new JarFile( result.getArtifact().getFile() );
+        Enumeration e = jarFile.entries();
+
+        while ( e.hasMoreElements() )
+        {
+            JarEntry entry = (JarEntry) e.nextElement();
+            String name = entry.getName();
+
+            // filter out files that do not end in .class
+            if ( name.length() <= 6 || !name.substring( name.length() - 6 ).equals( ".class" ) )
+            {
+                continue;
+            }
+
+            // remove .class from the end and change format to use periods instead of forward slashes
+            name = name.substring( 0, name.length() - 6 ).replace( '/', '.' );
+            getLog().info( name );
+        }
+        jarFile.close();
+    }
+
+    public ProjectBuildingRequest buildBuildingRequest()
+            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 = StringUtils.split( artifact, ":" );
+            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 = StringUtils.split( remoteRepositories, "," );
+            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 )
+    {
+        ArtifactHandler artifactHandler = artifactHandlerManager.getArtifactHandler( dependableCoordinate.getType() );
+        DefaultArtifactCoordinate artifactCoordinate = new DefaultArtifactCoordinate();
+        artifactCoordinate.setGroupId( dependableCoordinate.getGroupId() );
+        artifactCoordinate.setArtifactId( dependableCoordinate.getArtifactId() );
+        artifactCoordinate.setVersion( dependableCoordinate.getVersion() );
+        artifactCoordinate.setClassifier( dependableCoordinate.getClassifier() );
+        artifactCoordinate.setExtension( artifactHandler.getExtension() );
+        return artifactCoordinate;
+    }
+
+    ArtifactRepository parseRepository( String repo, ArtifactRepositoryPolicy policy )
+            throws MojoFailureException
+    {
+        // if it's a simple url
+        String id = "temp";
+        ArtifactRepositoryLayout layout = getLayout( "default" );
+        String url = repo;

Review comment:
       why copy this value?

##########
File path: src/main/java/org/apache/maven/plugins/dependency/ListClassesMojo.java
##########
@@ -0,0 +1,402 @@
+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. ie.
+     * 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 = buildBuildingRequest();
+        DefaultDependableCoordinate coordinate = getCoordinate();
+
+        try
+        {
+            if ( isTransitive() )
+            {
+                Iterable<ArtifactResult> artifacts = getDependencyResolver()

Review comment:
       you can access fields like dependencyResolver directly. There's no need to use a getter method in the same class. 

##########
File path: src/main/java/org/apache/maven/plugins/dependency/ListClassesMojo.java
##########
@@ -0,0 +1,402 @@
+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. ie.

Review comment:
       avoid Latin. ie. --> That is,

##########
File path: src/main/java/org/apache/maven/plugins/dependency/ListClassesMojo.java
##########
@@ -0,0 +1,402 @@
+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. ie.
+     * 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 = buildBuildingRequest();
+        DefaultDependableCoordinate coordinate = getCoordinate();
+
+        try
+        {
+            if ( isTransitive() )
+            {
+                Iterable<ArtifactResult> artifacts = getDependencyResolver()
+                        .resolveDependencies( buildingRequest, coordinate, null );
+
+                for ( ArtifactResult result : artifacts )
+                {
+                    printClassesFromArtifactResult( result );
+                }
+            }
+            else
+            {
+                ArtifactResult result = getArtifactResolver()
+                        .resolveArtifact( buildingRequest, toArtifactCoordinate( coordinate ) );
+
+                printClassesFromArtifactResult( result );
+            }
+        }
+        catch ( ArtifactResolverException | DependencyResolverException | IOException e )
+        {
+            throw new MojoExecutionException( "Couldn't download artifact: " + e.getMessage(), e );

Review comment:
       exception message should contain coordinates of artifact it was trying to download

##########
File path: src/main/java/org/apache/maven/plugins/dependency/ListClassesMojo.java
##########
@@ -0,0 +1,402 @@
+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. ie.
+     * 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 = buildBuildingRequest();
+        DefaultDependableCoordinate coordinate = getCoordinate();
+
+        try
+        {
+            if ( isTransitive() )
+            {
+                Iterable<ArtifactResult> artifacts = getDependencyResolver()
+                        .resolveDependencies( buildingRequest, coordinate, null );
+
+                for ( ArtifactResult result : artifacts )
+                {
+                    printClassesFromArtifactResult( result );
+                }
+            }
+            else
+            {
+                ArtifactResult result = getArtifactResolver()
+                        .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
+    {
+        JarFile jarFile = new JarFile( result.getArtifact().getFile() );
+        Enumeration entries = jarFile.entries();
+
+        while ( entries.hasMoreElements() )
+        {
+            JarEntry entry = (JarEntry) entries.nextElement();
+            String name = entry.getName();
+
+            // filter out files that do not end in .class
+            if ( !name.endsWith( ".class" ) )
+            {
+                continue;
+            }
+
+            // remove .class from the end and change format to use periods instead of forward slashes
+            name = name.substring( 0, name.length() - 6 ).replace( '/', '.' );
+            getLog().info( name );
+        }
+        jarFile.close();
+    }
+
+    private ProjectBuildingRequest buildBuildingRequest()

Review comment:
       makeBuildingRequest?

##########
File path: src/main/java/org/apache/maven/plugins/dependency/ListClassesMojo.java
##########
@@ -0,0 +1,402 @@
+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. ie.
+     * 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 = buildBuildingRequest();
+        DefaultDependableCoordinate coordinate = getCoordinate();
+
+        try
+        {
+            if ( isTransitive() )
+            {
+                Iterable<ArtifactResult> artifacts = getDependencyResolver()
+                        .resolveDependencies( buildingRequest, coordinate, null );
+
+                for ( ArtifactResult result : artifacts )
+                {
+                    printClassesFromArtifactResult( result );
+                }
+            }
+            else
+            {
+                ArtifactResult result = getArtifactResolver()
+                        .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
+    {
+        JarFile jarFile = new JarFile( result.getArtifact().getFile() );
+        Enumeration entries = jarFile.entries();
+
+        while ( entries.hasMoreElements() )
+        {
+            JarEntry entry = (JarEntry) entries.nextElement();
+            String name = entry.getName();
+
+            // filter out files that do not end in .class
+            if ( !name.endsWith( ".class" ) )
+            {
+                continue;
+            }
+
+            // remove .class from the end and change format to use periods instead of forward slashes
+            name = name.substring( 0, name.length() - 6 ).replace( '/', '.' );

Review comment:
       try to avoid reusing local variables. Here you have two things: an entry name and a class name, so two different variables make this clearer

##########
File path: src/main/java/org/apache/maven/plugins/dependency/ListClassesMojo.java
##########
@@ -0,0 +1,402 @@
+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. ie.
+     * 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 = buildBuildingRequest();
+        DefaultDependableCoordinate coordinate = getCoordinate();
+
+        try
+        {
+            if ( isTransitive() )
+            {
+                Iterable<ArtifactResult> artifacts = getDependencyResolver()
+                        .resolveDependencies( buildingRequest, coordinate, null );
+
+                for ( ArtifactResult result : artifacts )
+                {
+                    printClassesFromArtifactResult( result );
+                }
+            }
+            else
+            {
+                ArtifactResult result = getArtifactResolver()
+                        .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
+    {
+        JarFile jarFile = new JarFile( result.getArtifact().getFile() );
+        Enumeration entries = jarFile.entries();
+
+        while ( entries.hasMoreElements() )
+        {
+            JarEntry entry = (JarEntry) entries.nextElement();
+            String name = entry.getName();
+
+            // filter out files that do not end in .class
+            if ( !name.endsWith( ".class" ) )
+            {
+                continue;
+            }
+
+            // remove .class from the end and change format to use periods instead of forward slashes
+            name = name.substring( 0, name.length() - 6 ).replace( '/', '.' );
+            getLog().info( name );
+        }
+        jarFile.close();
+    }
+
+    private ProjectBuildingRequest buildBuildingRequest()
+            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 )
+    {
+        ArtifactHandler artifactHandler = artifactHandlerManager.getArtifactHandler( dependableCoordinate.getType() );
+        DefaultArtifactCoordinate artifactCoordinate = new DefaultArtifactCoordinate();
+        artifactCoordinate.setGroupId( dependableCoordinate.getGroupId() );
+        artifactCoordinate.setArtifactId( dependableCoordinate.getArtifactId() );
+        artifactCoordinate.setVersion( dependableCoordinate.getVersion() );
+        artifactCoordinate.setClassifier( dependableCoordinate.getClassifier() );
+        artifactCoordinate.setExtension( artifactHandler.getExtension() );
+        return artifactCoordinate;
+    }
+
+    ArtifactRepository parseRepository( String repo, ArtifactRepositoryPolicy policy )
+            throws MojoFailureException
+    {
+        // if it's a simple url
+        String id = "temp";
+        ArtifactRepositoryLayout layout = getLayout( "default" );
+
+        // if it's an extended repo URL of the form id::layout::url
+        if ( repo.contains( "::" ) )
+        {
+            Matcher matcher = ALT_REPO_SYNTAX_PATTERN.matcher( repo );
+            if ( !matcher.matches() )
+            {
+                throw new MojoFailureException( repo, "Invalid syntax for repository: " + repo,
+                        "Invalid syntax for repository. Use \"id::layout::url\" or \"URL\"." );
+            }
+
+            id = matcher.group( 1 ).trim();
+            if ( !( matcher.group( 2 ) == null || matcher.group( 2 ).trim().isEmpty() ) )
+            {
+                layout = getLayout( matcher.group( 2 ).trim() );
+            }
+            repo = matcher.group( 3 ).trim();
+        }
+        return new MavenArtifactRepository( id, repo, layout, policy, policy );
+    }
+
+    private ArtifactRepositoryLayout getLayout( String id )
+            throws MojoFailureException
+    {
+        ArtifactRepositoryLayout layout = repositoryLayouts.get( id );
+
+        if ( layout == null )
+        {
+            throw new MojoFailureException( id, "Invalid repository layout", "Invalid repository layout: " + id );
+        }
+
+        return layout;
+    }
+
+    /**
+     * @return {@link #skip}
+     */
+    protected boolean isSkip()
+    {
+        return skip;
+    }
+
+    protected boolean isTransitive()
+    {
+        return transitive;
+    }
+
+    protected DefaultDependableCoordinate getCoordinate()
+    {
+        return coordinate;
+    }
+
+    protected DependencyResolver getDependencyResolver()
+    {
+        return dependencyResolver;
+    }
+
+    protected ArtifactResolver getArtifactResolver()

Review comment:
       do you need this method?

##########
File path: src/main/java/org/apache/maven/plugins/dependency/ListClassesMojo.java
##########
@@ -0,0 +1,402 @@
+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. ie.
+     * 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 = buildBuildingRequest();
+        DefaultDependableCoordinate coordinate = getCoordinate();

Review comment:
       don't shadow the field here

##########
File path: src/main/java/org/apache/maven/plugins/dependency/ListClassesMojo.java
##########
@@ -0,0 +1,402 @@
+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. ie.
+     * 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 = buildBuildingRequest();
+        DefaultDependableCoordinate coordinate = getCoordinate();
+
+        try
+        {
+            if ( isTransitive() )
+            {
+                Iterable<ArtifactResult> artifacts = getDependencyResolver()
+                        .resolveDependencies( buildingRequest, coordinate, null );
+
+                for ( ArtifactResult result : artifacts )
+                {
+                    printClassesFromArtifactResult( result );
+                }
+            }
+            else
+            {
+                ArtifactResult result = getArtifactResolver()
+                        .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
+    {
+        JarFile jarFile = new JarFile( result.getArtifact().getFile() );
+        Enumeration entries = jarFile.entries();
+
+        while ( entries.hasMoreElements() )
+        {
+            JarEntry entry = (JarEntry) entries.nextElement();
+            String name = entry.getName();
+
+            // filter out files that do not end in .class
+            if ( !name.endsWith( ".class" ) )
+            {
+                continue;
+            }
+
+            // remove .class from the end and change format to use periods instead of forward slashes
+            name = name.substring( 0, name.length() - 6 ).replace( '/', '.' );
+            getLog().info( name );
+        }
+        jarFile.close();
+    }
+
+    private ProjectBuildingRequest buildBuildingRequest()
+            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 )
+    {
+        ArtifactHandler artifactHandler = artifactHandlerManager.getArtifactHandler( dependableCoordinate.getType() );
+        DefaultArtifactCoordinate artifactCoordinate = new DefaultArtifactCoordinate();
+        artifactCoordinate.setGroupId( dependableCoordinate.getGroupId() );
+        artifactCoordinate.setArtifactId( dependableCoordinate.getArtifactId() );
+        artifactCoordinate.setVersion( dependableCoordinate.getVersion() );
+        artifactCoordinate.setClassifier( dependableCoordinate.getClassifier() );
+        artifactCoordinate.setExtension( artifactHandler.getExtension() );
+        return artifactCoordinate;
+    }
+
+    ArtifactRepository parseRepository( String repo, ArtifactRepositoryPolicy policy )
+            throws MojoFailureException
+    {
+        // if it's a simple url
+        String id = "temp";
+        ArtifactRepositoryLayout layout = getLayout( "default" );
+
+        // if it's an extended repo URL of the form id::layout::url
+        if ( repo.contains( "::" ) )
+        {
+            Matcher matcher = ALT_REPO_SYNTAX_PATTERN.matcher( repo );
+            if ( !matcher.matches() )
+            {
+                throw new MojoFailureException( repo, "Invalid syntax for repository: " + repo,
+                        "Invalid syntax for repository. Use \"id::layout::url\" or \"URL\"." );
+            }
+
+            id = matcher.group( 1 ).trim();
+            if ( !( matcher.group( 2 ) == null || matcher.group( 2 ).trim().isEmpty() ) )
+            {
+                layout = getLayout( matcher.group( 2 ).trim() );
+            }
+            repo = matcher.group( 3 ).trim();
+        }
+        return new MavenArtifactRepository( id, repo, layout, policy, policy );
+    }
+
+    private ArtifactRepositoryLayout getLayout( String id )
+            throws MojoFailureException
+    {
+        ArtifactRepositoryLayout layout = repositoryLayouts.get( id );
+
+        if ( layout == null )
+        {
+            throw new MojoFailureException( id, "Invalid repository layout", "Invalid repository layout: " + id );
+        }
+
+        return layout;
+    }
+
+    /**
+     * @return {@link #skip}
+     */
+    protected boolean isSkip()
+    {
+        return skip;
+    }
+
+    protected boolean isTransitive()
+    {
+        return transitive;
+    }
+
+    protected DefaultDependableCoordinate getCoordinate()
+    {
+        return coordinate;
+    }
+
+    protected DependencyResolver getDependencyResolver()
+    {
+        return dependencyResolver;
+    }
+
+    protected ArtifactResolver getArtifactResolver()
+    {
+        return artifactResolver;
+    }
+
+    /**
+     * @param artifact The artifact.

Review comment:
       https://www.oracle.com/technical-resources/articles/java/javadoc-tool.html#tag

##########
File path: src/main/java/org/apache/maven/plugins/dependency/ListClassesMojo.java
##########
@@ -0,0 +1,402 @@
+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();

Review comment:
       I don't understand the difference between this and an ArtifactCoordinate.




----------------------------------------------------------------
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



[GitHub] [maven-dependency-plugin] jonvolfson commented on a change in pull request #57: [MDEP-645] Created new mojo GetClassesMojo which lists all class dependencies for a specified artifact.

Posted by GitBox <gi...@apache.org>.
jonvolfson commented on a change in pull request #57:
URL: https://github.com/apache/maven-dependency-plugin/pull/57#discussion_r441029925



##########
File path: src/main/java/org/apache/maven/plugins/dependency/GetClassesMojo.java
##########
@@ -0,0 +1,406 @@
+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;
+import org.codehaus.plexus.util.StringUtils;
+
+
+/**
+ * Retrieves and lists all class dependencies for the specified artifact from the specified remote repositories.
+ */
+@Mojo( name = "get-classes", requiresProject = false, threadSafe = true )
+public class GetClassesMojo
+    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 groupId of the artifact to download. Ignored if {@link #artifact} is used.
+     */
+    @Parameter( property = "groupId" )
+    private String groupId;
+
+    /**
+     * The artifactId 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 url, separated by comma. ie.
+     * 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 = "true" )
+    private boolean transitive = true;
+
+    /**
+     * Skip plugin execution completely.
+     *
+     * @since 2.7
+     */
+    @Parameter( property = "mdep.skip", defaultValue = "false" )
+    private boolean skip;
+
+    @Override
+    public void execute() throws MojoExecutionException, MojoFailureException
+    {
+        ProjectBuildingRequest buildingRequest = buildBuildingRequest();
+        DefaultDependableCoordinate coordinate = getCoordinate();
+
+        try
+        {
+            getLog().info( "Retrieving classes of dependencies for " + artifact );
+            if ( isTransitive() )
+            {
+                Iterable<ArtifactResult> artifacts = getDependencyResolver()
+                        .resolveDependencies( buildingRequest, coordinate, null );
+
+                for ( ArtifactResult result : artifacts )
+                {
+                    printClassesFromArtifactResult( result );
+                }
+            }
+            else
+            {
+                ArtifactResult result = getArtifactResolver()
+                        .resolveArtifact( buildingRequest, toArtifactCoordinate( coordinate ) );
+
+                printClassesFromArtifactResult( result );
+            }
+        }
+        catch ( ArtifactResolverException | DependencyResolverException | IOException e )
+        {
+            throw new MojoExecutionException( "Couldn't download artifact: " + e.getMessage(), e );
+        }
+    }
+
+    public void printClassesFromArtifactResult( ArtifactResult result )
+            throws IOException
+    {
+        JarFile jarFile = new JarFile( result.getArtifact().getFile() );
+        Enumeration e = jarFile.entries();

Review comment:
       fixed, forgot to comment




----------------------------------------------------------------
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



[GitHub] [maven-dependency-plugin] jonvolfson commented on a change in pull request #57: [MDEP-645] Created new mojo GetClassesMojo which lists all class dependencies for a specified artifact.

Posted by GitBox <gi...@apache.org>.
jonvolfson commented on a change in pull request #57:
URL: https://github.com/apache/maven-dependency-plugin/pull/57#discussion_r431278352



##########
File path: src/main/java/org/apache/maven/plugins/dependency/ListClassesMojo.java
##########
@@ -0,0 +1,402 @@
+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. ie.
+     * 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 = buildBuildingRequest();
+        DefaultDependableCoordinate coordinate = getCoordinate();
+
+        try
+        {
+            if ( isTransitive() )
+            {
+                Iterable<ArtifactResult> artifacts = getDependencyResolver()
+                        .resolveDependencies( buildingRequest, coordinate, null );
+
+                for ( ArtifactResult result : artifacts )
+                {
+                    printClassesFromArtifactResult( result );
+                }
+            }
+            else
+            {
+                ArtifactResult result = getArtifactResolver()
+                        .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
+    {
+        JarFile jarFile = new JarFile( result.getArtifact().getFile() );
+        Enumeration entries = jarFile.entries();
+
+        while ( entries.hasMoreElements() )
+        {
+            JarEntry entry = (JarEntry) entries.nextElement();
+            String name = entry.getName();
+
+            // filter out files that do not end in .class
+            if ( !name.endsWith( ".class" ) )
+            {
+                continue;
+            }
+
+            // remove .class from the end and change format to use periods instead of forward slashes
+            name = name.substring( 0, name.length() - 6 ).replace( '/', '.' );
+            getLog().info( name );
+        }
+        jarFile.close();
+    }
+
+    private ProjectBuildingRequest buildBuildingRequest()
+            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 )
+    {
+        ArtifactHandler artifactHandler = artifactHandlerManager.getArtifactHandler( dependableCoordinate.getType() );
+        DefaultArtifactCoordinate artifactCoordinate = new DefaultArtifactCoordinate();
+        artifactCoordinate.setGroupId( dependableCoordinate.getGroupId() );
+        artifactCoordinate.setArtifactId( dependableCoordinate.getArtifactId() );
+        artifactCoordinate.setVersion( dependableCoordinate.getVersion() );
+        artifactCoordinate.setClassifier( dependableCoordinate.getClassifier() );
+        artifactCoordinate.setExtension( artifactHandler.getExtension() );
+        return artifactCoordinate;
+    }
+
+    ArtifactRepository parseRepository( String repo, ArtifactRepositoryPolicy policy )
+            throws MojoFailureException
+    {
+        // if it's a simple url
+        String id = "temp";
+        ArtifactRepositoryLayout layout = getLayout( "default" );
+
+        // if it's an extended repo URL of the form id::layout::url
+        if ( repo.contains( "::" ) )
+        {
+            Matcher matcher = ALT_REPO_SYNTAX_PATTERN.matcher( repo );
+            if ( !matcher.matches() )
+            {
+                throw new MojoFailureException( repo, "Invalid syntax for repository: " + repo,
+                        "Invalid syntax for repository. Use \"id::layout::url\" or \"URL\"." );
+            }
+
+            id = matcher.group( 1 ).trim();
+            if ( !( matcher.group( 2 ) == null || matcher.group( 2 ).trim().isEmpty() ) )
+            {
+                layout = getLayout( matcher.group( 2 ).trim() );
+            }
+            repo = matcher.group( 3 ).trim();
+        }
+        return new MavenArtifactRepository( id, repo, layout, policy, policy );
+    }
+
+    private ArtifactRepositoryLayout getLayout( String id )
+            throws MojoFailureException
+    {
+        ArtifactRepositoryLayout layout = repositoryLayouts.get( id );
+
+        if ( layout == null )
+        {
+            throw new MojoFailureException( id, "Invalid repository layout", "Invalid repository layout: " + id );
+        }
+
+        return layout;
+    }
+
+    /**
+     * @return {@link #skip}
+     */
+    protected boolean isSkip()
+    {
+        return skip;
+    }
+
+    protected boolean isTransitive()
+    {
+        return transitive;
+    }
+
+    protected DefaultDependableCoordinate getCoordinate()
+    {
+        return coordinate;
+    }
+
+    protected DependencyResolver getDependencyResolver()
+    {
+        return dependencyResolver;
+    }
+
+    protected ArtifactResolver getArtifactResolver()

Review comment:
       fixed, removed this method and other getters that weren't needed

##########
File path: src/main/java/org/apache/maven/plugins/dependency/ListClassesMojo.java
##########
@@ -0,0 +1,402 @@
+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. ie.

Review comment:
       fixed




----------------------------------------------------------------
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



[GitHub] [maven-dependency-plugin] jonvolfson commented on a change in pull request #57: [MDEP-645] Created new mojo GetClassesMojo which lists all class dependencies for a specified artifact.

Posted by GitBox <gi...@apache.org>.
jonvolfson commented on a change in pull request #57:
URL: https://github.com/apache/maven-dependency-plugin/pull/57#discussion_r430519833



##########
File path: src/test/java/org/apache/maven/plugins/dependency/TestGetClassesMojo.java
##########
@@ -0,0 +1,88 @@
+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 org.apache.maven.execution.MavenSession;
+import org.apache.maven.plugin.LegacySupport;
+import org.apache.maven.plugin.testing.stubs.MavenProjectStub;
+import org.apache.maven.settings.Server;
+import org.apache.maven.settings.Settings;
+import org.sonatype.aether.impl.internal.SimpleLocalRepositoryManager;
+import org.sonatype.aether.util.DefaultRepositorySystemSession;
+
+import java.io.File;
+
+public class TestGetClassesMojo
+        extends AbstractDependencyMojoTestCase
+{
+    GetClassesMojo mojo;
+
+    protected void setUp()
+            throws Exception
+    {
+        // required for mojo lookups to work
+        super.setUp( "markers", false );
+
+        File testPom = new File( getBasedir(), "target/test-classes/unit/get-test/plugin-config.xml" );
+        assert testPom.exists();
+        mojo = (GetClassesMojo) lookupMojo( "get-classes", testPom );
+
+        assertNotNull( mojo );
+
+        LegacySupport legacySupport = lookup( LegacySupport.class );
+        MavenSession session = newMavenSession( new MavenProjectStub() );
+        Settings settings = session.getSettings();
+        Server server = new Server();
+        server.setId( "myserver" );
+        server.setUsername( "foo" );
+        server.setPassword( "bar" );
+        settings.addServer( server );
+        legacySupport.setSession( session );
+        DefaultRepositorySystemSession repoSession =
+                (DefaultRepositorySystemSession) legacySupport.getRepositorySession();
+        repoSession.setLocalRepositoryManager( new SimpleLocalRepositoryManager( testDir.getAbsolutePath() ) );
+
+        setVariableValueToObject( mojo, "session", legacySupport.getSession() );
+    }
+
+    public void testGetClassesNotTransitive()
+            throws Exception
+    {
+        setVariableValueToObject( mojo, "remoteRepositories", "central::default::https://repo.maven.apache.org/maven2,"
+                + "central::::https://repo.maven.apache.org/maven2," + "https://repo.maven.apache.org/maven2" );
+        mojo.setArtifact("org.apache.commons:commons-lang3:3.6");
+        setVariableValueToObject( mojo, "transitive", Boolean.FALSE );
+
+        mojo.execute();
+        return;
+    }
+
+    public void testGetClassesTransitive()

Review comment:
       When listing classes for something like org.apache.maven:maven-model:2.0.9, setting -Dtransitive=true lists more classes than the false alternative. It's possible that the artifact used in the test has little/no transitive dependencies which means the results would be similar/the same.

##########
File path: src/main/java/org/apache/maven/plugins/dependency/GetClassesMojo.java
##########
@@ -0,0 +1,396 @@
+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;
+import org.codehaus.plexus.util.StringUtils;
+
+@Mojo( name = "get-classes", requiresProject = false, threadSafe = true )
+public class GetClassesMojo
+    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 groupId of the artifact to download. Ignored if {@link #artifact} is used.
+     */
+    @Parameter( property = "groupId" )
+    private String groupId;
+
+    /**
+     * The artifactId 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 url, separated by comma. ie.
+     * 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 = "true" )
+    private boolean transitive = true;
+
+    /**
+     * Skip plugin execution completely.
+     *
+     * @since 2.7
+     */
+    @Parameter( property = "mdep.skip", defaultValue = "false" )
+    private boolean skip;
+
+    @Override
+    public void execute() throws MojoExecutionException, MojoFailureException
+    {
+        ProjectBuildingRequest buildingRequest = buildBuildingRequest();
+        DefaultDependableCoordinate coordinate = getCoordinate();
+
+        try
+        {
+            getLog().info( "Retrieving classes of dependencies for " + artifact );
+            if ( isTransitive() )
+            {
+                Iterable<ArtifactResult> artifacts = getDependencyResolver().resolveDependencies( buildingRequest, coordinate, null );
+
+                for ( ArtifactResult result : artifacts )
+                {
+                    printClassesFromArtifactResult( result );
+                }
+            }
+            else
+            {
+                ArtifactResult result = getArtifactResolver().resolveArtifact( buildingRequest, toArtifactCoordinate( coordinate ) );
+
+                printClassesFromArtifactResult( result );
+            }
+        }
+        catch ( ArtifactResolverException | DependencyResolverException | IOException e )
+        {
+            throw new MojoExecutionException( "Couldn't download artifact: " + e.getMessage(), e );
+        }
+    }
+
+    public void printClassesFromArtifactResult( ArtifactResult result )
+            throws IOException
+    {
+        JarFile jarFile = new JarFile( result.getArtifact().getFile() );
+        Enumeration e = jarFile.entries();
+
+        while ( e.hasMoreElements() )
+        {
+            JarEntry entry = ( JarEntry )e.nextElement();
+            String name = entry.getName();
+
+            // filter out files that do not end in .class
+            if ( name.length() <= 6 || !name.substring( name.length() - 6 ).equals( ".class" )) {
+                continue;
+            }
+
+            // remove .class from the end and change format to use periods instead of forward slashes
+            name = name.substring( 0, name.length() - 6 ).replace( '/', '.' );
+            getLog().info( name );
+        }
+        jarFile.close();
+    }
+
+    public ProjectBuildingRequest buildBuildingRequest()
+            throws MojoExecutionException, MojoFailureException
+    {
+        if ( coordinate.getArtifactId() == null && artifact == null )

Review comment:
       Fixed. Removed the coordinate.getArtifactId() part. This was recycled code from the GetMojo with a similar use case.

##########
File path: src/test/java/org/apache/maven/plugins/dependency/TestGetClassesMojo.java
##########
@@ -0,0 +1,88 @@
+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 org.apache.maven.execution.MavenSession;
+import org.apache.maven.plugin.LegacySupport;
+import org.apache.maven.plugin.testing.stubs.MavenProjectStub;
+import org.apache.maven.settings.Server;
+import org.apache.maven.settings.Settings;
+import org.sonatype.aether.impl.internal.SimpleLocalRepositoryManager;
+import org.sonatype.aether.util.DefaultRepositorySystemSession;
+
+import java.io.File;
+
+public class TestGetClassesMojo
+        extends AbstractDependencyMojoTestCase
+{
+    GetClassesMojo mojo;
+
+    protected void setUp()
+            throws Exception
+    {
+        // required for mojo lookups to work
+        super.setUp( "markers", false );
+
+        File testPom = new File( getBasedir(), "target/test-classes/unit/get-test/plugin-config.xml" );
+        assert testPom.exists();
+        mojo = (GetClassesMojo) lookupMojo( "get-classes", testPom );
+
+        assertNotNull( mojo );
+
+        LegacySupport legacySupport = lookup( LegacySupport.class );
+        MavenSession session = newMavenSession( new MavenProjectStub() );
+        Settings settings = session.getSettings();
+        Server server = new Server();
+        server.setId( "myserver" );
+        server.setUsername( "foo" );
+        server.setPassword( "bar" );
+        settings.addServer( server );
+        legacySupport.setSession( session );
+        DefaultRepositorySystemSession repoSession =
+                (DefaultRepositorySystemSession) legacySupport.getRepositorySession();
+        repoSession.setLocalRepositoryManager( new SimpleLocalRepositoryManager( testDir.getAbsolutePath() ) );
+
+        setVariableValueToObject( mojo, "session", legacySupport.getSession() );
+    }
+
+    public void testGetClassesNotTransitive()
+            throws Exception
+    {
+        setVariableValueToObject( mojo, "remoteRepositories", "central::default::https://repo.maven.apache.org/maven2,"
+                + "central::::https://repo.maven.apache.org/maven2," + "https://repo.maven.apache.org/maven2" );
+        mojo.setArtifact("org.apache.commons:commons-lang3:3.6");
+        setVariableValueToObject( mojo, "transitive", Boolean.FALSE );
+
+        mojo.execute();
+        return;

Review comment:
       Fixed.

##########
File path: src/test/java/org/apache/maven/plugins/dependency/TestGetClassesMojo.java
##########
@@ -0,0 +1,88 @@
+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 org.apache.maven.execution.MavenSession;
+import org.apache.maven.plugin.LegacySupport;
+import org.apache.maven.plugin.testing.stubs.MavenProjectStub;
+import org.apache.maven.settings.Server;
+import org.apache.maven.settings.Settings;
+import org.sonatype.aether.impl.internal.SimpleLocalRepositoryManager;
+import org.sonatype.aether.util.DefaultRepositorySystemSession;
+
+import java.io.File;
+
+public class TestGetClassesMojo
+        extends AbstractDependencyMojoTestCase
+{
+    GetClassesMojo mojo;
+
+    protected void setUp()
+            throws Exception
+    {
+        // required for mojo lookups to work
+        super.setUp( "markers", false );
+
+        File testPom = new File( getBasedir(), "target/test-classes/unit/get-test/plugin-config.xml" );
+        assert testPom.exists();
+        mojo = (GetClassesMojo) lookupMojo( "get-classes", testPom );
+
+        assertNotNull( mojo );
+
+        LegacySupport legacySupport = lookup( LegacySupport.class );
+        MavenSession session = newMavenSession( new MavenProjectStub() );
+        Settings settings = session.getSettings();
+        Server server = new Server();
+        server.setId( "myserver" );
+        server.setUsername( "foo" );
+        server.setPassword( "bar" );
+        settings.addServer( server );
+        legacySupport.setSession( session );
+        DefaultRepositorySystemSession repoSession =
+                (DefaultRepositorySystemSession) legacySupport.getRepositorySession();
+        repoSession.setLocalRepositoryManager( new SimpleLocalRepositoryManager( testDir.getAbsolutePath() ) );
+
+        setVariableValueToObject( mojo, "session", legacySupport.getSession() );
+    }
+
+    public void testGetClassesNotTransitive()
+            throws Exception
+    {
+        setVariableValueToObject( mojo, "remoteRepositories", "central::default::https://repo.maven.apache.org/maven2,"
+                + "central::::https://repo.maven.apache.org/maven2," + "https://repo.maven.apache.org/maven2" );
+        mojo.setArtifact("org.apache.commons:commons-lang3:3.6");
+        setVariableValueToObject( mojo, "transitive", Boolean.FALSE );
+
+        mojo.execute();
+        return;
+    }
+
+    public void testGetClassesTransitive()
+            throws Exception
+    {
+        setVariableValueToObject( mojo, "remoteRepositories", "central::default::https://repo.maven.apache.org/maven2,"
+                + "central::::https://repo.maven.apache.org/maven2," + "https://repo.maven.apache.org/maven2" );
+        mojo.setArtifact("org.apache.commons:commons-lang3:3.6");
+        setVariableValueToObject( mojo, "transitive", Boolean.TRUE );
+
+        mojo.execute();
+        return;

Review comment:
       Fixed.

##########
File path: src/main/java/org/apache/maven/plugins/dependency/GetClassesMojo.java
##########
@@ -0,0 +1,406 @@
+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;
+import org.codehaus.plexus.util.StringUtils;
+
+
+/**
+ * Retrieves and lists all class dependencies for the specified artifact from the specified remote repositories.
+ */
+@Mojo( name = "get-classes", requiresProject = false, threadSafe = true )
+public class GetClassesMojo
+    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 groupId of the artifact to download. Ignored if {@link #artifact} is used.
+     */
+    @Parameter( property = "groupId" )
+    private String groupId;
+
+    /**
+     * The artifactId 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 url, separated by comma. ie.
+     * 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.

Review comment:
       I'm not sure if this is a useful feature to have but in case it is, I've set the default to false for now instead of removing it altogether.

##########
File path: src/main/java/org/apache/maven/plugins/dependency/GetClassesMojo.java
##########
@@ -0,0 +1,406 @@
+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;
+import org.codehaus.plexus.util.StringUtils;
+
+
+/**
+ * Retrieves and lists all class dependencies for the specified artifact from the specified remote repositories.

Review comment:
       fixed

##########
File path: src/main/java/org/apache/maven/plugins/dependency/GetClassesMojo.java
##########
@@ -0,0 +1,406 @@
+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;
+import org.codehaus.plexus.util.StringUtils;
+
+
+/**
+ * Retrieves and lists all class dependencies for the specified artifact from the specified remote repositories.
+ */
+@Mojo( name = "get-classes", requiresProject = false, threadSafe = true )
+public class GetClassesMojo

Review comment:
       fixed

##########
File path: src/main/java/org/apache/maven/plugins/dependency/GetClassesMojo.java
##########
@@ -0,0 +1,406 @@
+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;
+import org.codehaus.plexus.util.StringUtils;
+
+
+/**
+ * Retrieves and lists all class dependencies for the specified artifact from the specified remote repositories.
+ */
+@Mojo( name = "get-classes", requiresProject = false, threadSafe = true )
+public class GetClassesMojo
+    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 groupId of the artifact to download. Ignored if {@link #artifact} is used.

Review comment:
       fixed

##########
File path: src/main/java/org/apache/maven/plugins/dependency/GetClassesMojo.java
##########
@@ -0,0 +1,406 @@
+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;
+import org.codehaus.plexus.util.StringUtils;
+
+
+/**
+ * Retrieves and lists all class dependencies for the specified artifact from the specified remote repositories.
+ */
+@Mojo( name = "get-classes", requiresProject = false, threadSafe = true )
+public class GetClassesMojo
+    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 groupId of the artifact to download. Ignored if {@link #artifact} is used.
+     */
+    @Parameter( property = "groupId" )
+    private String groupId;
+
+    /**
+     * The artifactId of the artifact to download. Ignored if {@link #artifact} is used.

Review comment:
       fixed

##########
File path: src/main/java/org/apache/maven/plugins/dependency/GetClassesMojo.java
##########
@@ -0,0 +1,406 @@
+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;
+import org.codehaus.plexus.util.StringUtils;
+
+
+/**
+ * Retrieves and lists all class dependencies for the specified artifact from the specified remote repositories.
+ */
+@Mojo( name = "get-classes", requiresProject = false, threadSafe = true )
+public class GetClassesMojo
+    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 groupId of the artifact to download. Ignored if {@link #artifact} is used.
+     */
+    @Parameter( property = "groupId" )
+    private String groupId;
+
+    /**
+     * The artifactId 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 url, separated by comma. ie.
+     * 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 = "true" )
+    private boolean transitive = true;
+
+    /**
+     * Skip plugin execution completely.
+     *
+     * @since 2.7
+     */
+    @Parameter( property = "mdep.skip", defaultValue = "false" )
+    private boolean skip;
+
+    @Override
+    public void execute() throws MojoExecutionException, MojoFailureException
+    {
+        ProjectBuildingRequest buildingRequest = buildBuildingRequest();
+        DefaultDependableCoordinate coordinate = getCoordinate();
+
+        try
+        {
+            getLog().info( "Retrieving classes of dependencies for " + artifact );
+            if ( isTransitive() )
+            {
+                Iterable<ArtifactResult> artifacts = getDependencyResolver()
+                        .resolveDependencies( buildingRequest, coordinate, null );
+
+                for ( ArtifactResult result : artifacts )
+                {
+                    printClassesFromArtifactResult( result );
+                }
+            }
+            else
+            {
+                ArtifactResult result = getArtifactResolver()
+                        .resolveArtifact( buildingRequest, toArtifactCoordinate( coordinate ) );
+
+                printClassesFromArtifactResult( result );
+            }
+        }
+        catch ( ArtifactResolverException | DependencyResolverException | IOException e )
+        {
+            throw new MojoExecutionException( "Couldn't download artifact: " + e.getMessage(), e );
+        }
+    }
+
+    public void printClassesFromArtifactResult( ArtifactResult result )
+            throws IOException
+    {
+        JarFile jarFile = new JarFile( result.getArtifact().getFile() );
+        Enumeration e = jarFile.entries();
+
+        while ( e.hasMoreElements() )
+        {
+            JarEntry entry = (JarEntry) e.nextElement();
+            String name = entry.getName();
+
+            // filter out files that do not end in .class
+            if ( name.length() <= 6 || !name.substring( name.length() - 6 ).equals( ".class" ) )
+            {
+                continue;
+            }
+
+            // remove .class from the end and change format to use periods instead of forward slashes
+            name = name.substring( 0, name.length() - 6 ).replace( '/', '.' );
+            getLog().info( name );
+        }
+        jarFile.close();
+    }
+
+    public ProjectBuildingRequest buildBuildingRequest()
+            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 = StringUtils.split( artifact, ":" );
+            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 = StringUtils.split( remoteRepositories, "," );
+            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 )
+    {
+        ArtifactHandler artifactHandler = artifactHandlerManager.getArtifactHandler( dependableCoordinate.getType() );
+        DefaultArtifactCoordinate artifactCoordinate = new DefaultArtifactCoordinate();
+        artifactCoordinate.setGroupId( dependableCoordinate.getGroupId() );
+        artifactCoordinate.setArtifactId( dependableCoordinate.getArtifactId() );
+        artifactCoordinate.setVersion( dependableCoordinate.getVersion() );
+        artifactCoordinate.setClassifier( dependableCoordinate.getClassifier() );
+        artifactCoordinate.setExtension( artifactHandler.getExtension() );
+        return artifactCoordinate;
+    }
+
+    ArtifactRepository parseRepository( String repo, ArtifactRepositoryPolicy policy )
+            throws MojoFailureException
+    {
+        // if it's a simple url
+        String id = "temp";
+        ArtifactRepositoryLayout layout = getLayout( "default" );
+        String url = repo;
+
+        // if it's an extended repo URL of the form id::layout::url
+        if ( repo.contains( "::" ) )
+        {
+            Matcher matcher = ALT_REPO_SYNTAX_PATTERN.matcher( repo );
+            if ( !matcher.matches() )
+            {
+                throw new MojoFailureException( repo, "Invalid syntax for repository: " + repo,
+                        "Invalid syntax for repository. Use \"id::layout::url\" or \"URL\"." );
+            }
+
+            id = matcher.group( 1 ).trim();
+            if ( !StringUtils.isEmpty( matcher.group( 2 ) ) )
+            {
+                layout = getLayout( matcher.group( 2 ).trim() );
+            }
+            url = matcher.group( 3 ).trim();
+        }
+        return new MavenArtifactRepository( id, url, layout, policy, policy );
+    }
+
+    private ArtifactRepositoryLayout getLayout( String id )
+            throws MojoFailureException
+    {
+        ArtifactRepositoryLayout layout = repositoryLayouts.get( id );
+
+        if ( layout == null )
+        {
+            throw new MojoFailureException( id, "Invalid repository layout", "Invalid repository layout: " + id );
+        }
+
+        return layout;
+    }
+
+    /**
+     * @return {@link #skip}
+     */
+    protected boolean isSkip()
+    {
+        return skip;
+    }
+
+    protected boolean isTransitive()
+    {
+        return transitive;
+    }
+
+    protected DefaultDependableCoordinate getCoordinate()
+    {
+        return coordinate;
+    }
+
+    protected DependencyResolver getDependencyResolver()
+    {
+        return dependencyResolver;
+    }
+
+    protected ArtifactResolver getArtifactResolver()
+    {
+        return artifactResolver;
+    }
+
+    /**
+     * @param artifact The artifact

Review comment:
       More clarification? This is taken from the GetMojo. 

##########
File path: src/main/java/org/apache/maven/plugins/dependency/GetClassesMojo.java
##########
@@ -0,0 +1,406 @@
+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;
+import org.codehaus.plexus.util.StringUtils;
+
+
+/**
+ * Retrieves and lists all class dependencies for the specified artifact from the specified remote repositories.
+ */
+@Mojo( name = "get-classes", requiresProject = false, threadSafe = true )
+public class GetClassesMojo
+    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 groupId of the artifact to download. Ignored if {@link #artifact} is used.
+     */
+    @Parameter( property = "groupId" )
+    private String groupId;
+
+    /**
+     * The artifactId 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 url, separated by comma. ie.
+     * 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 = "true" )
+    private boolean transitive = true;
+
+    /**
+     * Skip plugin execution completely.
+     *
+     * @since 2.7
+     */
+    @Parameter( property = "mdep.skip", defaultValue = "false" )
+    private boolean skip;
+
+    @Override
+    public void execute() throws MojoExecutionException, MojoFailureException
+    {
+        ProjectBuildingRequest buildingRequest = buildBuildingRequest();
+        DefaultDependableCoordinate coordinate = getCoordinate();
+
+        try
+        {
+            getLog().info( "Retrieving classes of dependencies for " + artifact );
+            if ( isTransitive() )
+            {
+                Iterable<ArtifactResult> artifacts = getDependencyResolver()
+                        .resolveDependencies( buildingRequest, coordinate, null );
+
+                for ( ArtifactResult result : artifacts )
+                {
+                    printClassesFromArtifactResult( result );
+                }
+            }
+            else
+            {
+                ArtifactResult result = getArtifactResolver()
+                        .resolveArtifact( buildingRequest, toArtifactCoordinate( coordinate ) );
+
+                printClassesFromArtifactResult( result );
+            }
+        }
+        catch ( ArtifactResolverException | DependencyResolverException | IOException e )
+        {
+            throw new MojoExecutionException( "Couldn't download artifact: " + e.getMessage(), e );
+        }
+    }
+
+    public void printClassesFromArtifactResult( ArtifactResult result )
+            throws IOException
+    {
+        JarFile jarFile = new JarFile( result.getArtifact().getFile() );
+        Enumeration e = jarFile.entries();
+
+        while ( e.hasMoreElements() )
+        {
+            JarEntry entry = (JarEntry) e.nextElement();
+            String name = entry.getName();
+
+            // filter out files that do not end in .class
+            if ( name.length() <= 6 || !name.substring( name.length() - 6 ).equals( ".class" ) )
+            {
+                continue;
+            }
+
+            // remove .class from the end and change format to use periods instead of forward slashes
+            name = name.substring( 0, name.length() - 6 ).replace( '/', '.' );
+            getLog().info( name );
+        }
+        jarFile.close();
+    }
+
+    public ProjectBuildingRequest buildBuildingRequest()
+            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 = StringUtils.split( artifact, ":" );
+            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 = StringUtils.split( remoteRepositories, "," );
+            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 )
+    {
+        ArtifactHandler artifactHandler = artifactHandlerManager.getArtifactHandler( dependableCoordinate.getType() );
+        DefaultArtifactCoordinate artifactCoordinate = new DefaultArtifactCoordinate();
+        artifactCoordinate.setGroupId( dependableCoordinate.getGroupId() );
+        artifactCoordinate.setArtifactId( dependableCoordinate.getArtifactId() );
+        artifactCoordinate.setVersion( dependableCoordinate.getVersion() );
+        artifactCoordinate.setClassifier( dependableCoordinate.getClassifier() );
+        artifactCoordinate.setExtension( artifactHandler.getExtension() );
+        return artifactCoordinate;
+    }
+
+    ArtifactRepository parseRepository( String repo, ArtifactRepositoryPolicy policy )
+            throws MojoFailureException
+    {
+        // if it's a simple url
+        String id = "temp";
+        ArtifactRepositoryLayout layout = getLayout( "default" );
+        String url = repo;
+
+        // if it's an extended repo URL of the form id::layout::url
+        if ( repo.contains( "::" ) )
+        {
+            Matcher matcher = ALT_REPO_SYNTAX_PATTERN.matcher( repo );
+            if ( !matcher.matches() )
+            {
+                throw new MojoFailureException( repo, "Invalid syntax for repository: " + repo,
+                        "Invalid syntax for repository. Use \"id::layout::url\" or \"URL\"." );
+            }
+
+            id = matcher.group( 1 ).trim();
+            if ( !StringUtils.isEmpty( matcher.group( 2 ) ) )
+            {
+                layout = getLayout( matcher.group( 2 ).trim() );
+            }
+            url = matcher.group( 3 ).trim();
+        }
+        return new MavenArtifactRepository( id, url, layout, policy, policy );
+    }
+
+    private ArtifactRepositoryLayout getLayout( String id )
+            throws MojoFailureException
+    {
+        ArtifactRepositoryLayout layout = repositoryLayouts.get( id );
+
+        if ( layout == null )
+        {
+            throw new MojoFailureException( id, "Invalid repository layout", "Invalid repository layout: " + id );
+        }
+
+        return layout;
+    }
+
+    /**
+     * @return {@link #skip}
+     */
+    protected boolean isSkip()
+    {
+        return skip;
+    }
+
+    protected boolean isTransitive()
+    {
+        return transitive;
+    }
+
+    protected DefaultDependableCoordinate getCoordinate()
+    {
+        return coordinate;
+    }
+
+    protected DependencyResolver getDependencyResolver()
+    {
+        return dependencyResolver;
+    }
+
+    protected ArtifactResolver getArtifactResolver()
+    {
+        return artifactResolver;
+    }
+
+    /**
+     * @param artifact The artifact
+     */
+    public void setArtifact( String artifact )
+    {
+        this.artifact = artifact;
+    }
+
+    /**
+     * @param groupId The groupId.
+     */
+    public void setGroupId( String groupId )
+    {
+        this.coordinate.setGroupId( groupId );
+    }
+
+    /**
+     * @param artifactId The artifactId.

Review comment:
       fixed

##########
File path: src/test/java/org/apache/maven/plugins/dependency/TestGetClassesMojo.java
##########
@@ -0,0 +1,86 @@
+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 org.apache.maven.execution.MavenSession;
+import org.apache.maven.plugin.LegacySupport;
+import org.apache.maven.plugin.testing.stubs.MavenProjectStub;
+import org.apache.maven.settings.Server;
+import org.apache.maven.settings.Settings;
+import org.sonatype.aether.impl.internal.SimpleLocalRepositoryManager;
+import org.sonatype.aether.util.DefaultRepositorySystemSession;
+
+import java.io.File;
+
+public class TestGetClassesMojo
+        extends AbstractDependencyMojoTestCase
+{
+    GetClassesMojo mojo;
+
+    protected void setUp()
+            throws Exception
+    {
+        // required for mojo lookups to work
+        super.setUp( "markers", false );
+
+        File testPom = new File( getBasedir(), "target/test-classes/unit/get-test/plugin-config.xml" );
+        assert testPom.exists();

Review comment:
       fixed




----------------------------------------------------------------
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



[GitHub] [maven-dependency-plugin] jonvolfson commented on a change in pull request #57: [MDEP-645] Created new mojo GetClassesMojo which lists all class dependencies for a specified artifact.

Posted by GitBox <gi...@apache.org>.
jonvolfson commented on a change in pull request #57:
URL: https://github.com/apache/maven-dependency-plugin/pull/57#discussion_r441031230



##########
File path: src/main/java/org/apache/maven/plugins/dependency/GetClassesMojo.java
##########
@@ -0,0 +1,406 @@
+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;
+import org.codehaus.plexus.util.StringUtils;
+
+
+/**
+ * Retrieves and lists all class dependencies for the specified artifact from the specified remote repositories.
+ */
+@Mojo( name = "get-classes", requiresProject = false, threadSafe = true )
+public class GetClassesMojo
+    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 groupId of the artifact to download. Ignored if {@link #artifact} is used.
+     */
+    @Parameter( property = "groupId" )
+    private String groupId;
+
+    /**
+     * The artifactId 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 url, separated by comma. ie.
+     * 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 = "true" )
+    private boolean transitive = true;
+
+    /**
+     * Skip plugin execution completely.
+     *
+     * @since 2.7
+     */
+    @Parameter( property = "mdep.skip", defaultValue = "false" )
+    private boolean skip;
+
+    @Override
+    public void execute() throws MojoExecutionException, MojoFailureException
+    {
+        ProjectBuildingRequest buildingRequest = buildBuildingRequest();
+        DefaultDependableCoordinate coordinate = getCoordinate();
+
+        try
+        {
+            getLog().info( "Retrieving classes of dependencies for " + artifact );
+            if ( isTransitive() )
+            {
+                Iterable<ArtifactResult> artifacts = getDependencyResolver()
+                        .resolveDependencies( buildingRequest, coordinate, null );
+
+                for ( ArtifactResult result : artifacts )
+                {
+                    printClassesFromArtifactResult( result );
+                }
+            }
+            else
+            {
+                ArtifactResult result = getArtifactResolver()
+                        .resolveArtifact( buildingRequest, toArtifactCoordinate( coordinate ) );
+
+                printClassesFromArtifactResult( result );
+            }
+        }
+        catch ( ArtifactResolverException | DependencyResolverException | IOException e )
+        {
+            throw new MojoExecutionException( "Couldn't download artifact: " + e.getMessage(), e );
+        }
+    }
+
+    public void printClassesFromArtifactResult( ArtifactResult result )
+            throws IOException
+    {
+        JarFile jarFile = new JarFile( result.getArtifact().getFile() );
+        Enumeration e = jarFile.entries();
+
+        while ( e.hasMoreElements() )
+        {
+            JarEntry entry = (JarEntry) e.nextElement();
+            String name = entry.getName();
+
+            // filter out files that do not end in .class
+            if ( name.length() <= 6 || !name.substring( name.length() - 6 ).equals( ".class" ) )
+            {
+                continue;
+            }
+
+            // remove .class from the end and change format to use periods instead of forward slashes
+            name = name.substring( 0, name.length() - 6 ).replace( '/', '.' );
+            getLog().info( name );
+        }
+        jarFile.close();
+    }
+
+    public ProjectBuildingRequest buildBuildingRequest()
+            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 = StringUtils.split( artifact, ":" );
+            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 = StringUtils.split( remoteRepositories, "," );
+            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 )
+    {
+        ArtifactHandler artifactHandler = artifactHandlerManager.getArtifactHandler( dependableCoordinate.getType() );
+        DefaultArtifactCoordinate artifactCoordinate = new DefaultArtifactCoordinate();
+        artifactCoordinate.setGroupId( dependableCoordinate.getGroupId() );
+        artifactCoordinate.setArtifactId( dependableCoordinate.getArtifactId() );
+        artifactCoordinate.setVersion( dependableCoordinate.getVersion() );
+        artifactCoordinate.setClassifier( dependableCoordinate.getClassifier() );
+        artifactCoordinate.setExtension( artifactHandler.getExtension() );
+        return artifactCoordinate;
+    }
+
+    ArtifactRepository parseRepository( String repo, ArtifactRepositoryPolicy policy )
+            throws MojoFailureException
+    {
+        // if it's a simple url
+        String id = "temp";
+        ArtifactRepositoryLayout layout = getLayout( "default" );
+        String url = repo;

Review comment:
       fixed, removed unneeded variable




----------------------------------------------------------------
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



[GitHub] [maven-dependency-plugin] khmarbaise commented on pull request #57: Created new mojo GetClassesMojo which lists all class dependencies for a specified artifact.

Posted by GitBox <gi...@apache.org>.
khmarbaise commented on pull request #57:
URL: https://github.com/apache/maven-dependency-plugin/pull/57#issuecomment-634095974


   First please create an appropriate JIRA issue for that and describe the use case for this. 


----------------------------------------------------------------
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



[GitHub] [maven-dependency-plugin] bimargulies-google commented on a change in pull request #57: [MDEP-645] Created new mojo GetClassesMojo which lists all class dependencies for a specified artifact.

Posted by GitBox <gi...@apache.org>.
bimargulies-google commented on a change in pull request #57:
URL: https://github.com/apache/maven-dependency-plugin/pull/57#discussion_r430506873



##########
File path: src/main/java/org/apache/maven/plugins/dependency/GetClassesMojo.java
##########
@@ -0,0 +1,396 @@
+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;
+import org.codehaus.plexus.util.StringUtils;
+
+@Mojo( name = "get-classes", requiresProject = false, threadSafe = true )
+public class GetClassesMojo
+    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 groupId of the artifact to download. Ignored if {@link #artifact} is used.
+     */
+    @Parameter( property = "groupId" )
+    private String groupId;
+
+    /**
+     * The artifactId 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 url, separated by comma. ie.
+     * 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 = "true" )
+    private boolean transitive = true;
+
+    /**
+     * Skip plugin execution completely.
+     *
+     * @since 2.7
+     */
+    @Parameter( property = "mdep.skip", defaultValue = "false" )
+    private boolean skip;
+
+    @Override
+    public void execute() throws MojoExecutionException, MojoFailureException
+    {
+        ProjectBuildingRequest buildingRequest = buildBuildingRequest();
+        DefaultDependableCoordinate coordinate = getCoordinate();
+
+        try
+        {
+            getLog().info( "Retrieving classes of dependencies for " + artifact );
+            if ( isTransitive() )
+            {
+                Iterable<ArtifactResult> artifacts = getDependencyResolver().resolveDependencies( buildingRequest, coordinate, null );
+
+                for ( ArtifactResult result : artifacts )
+                {
+                    printClassesFromArtifactResult( result );
+                }
+            }
+            else
+            {
+                ArtifactResult result = getArtifactResolver().resolveArtifact( buildingRequest, toArtifactCoordinate( coordinate ) );
+
+                printClassesFromArtifactResult( result );
+            }
+        }
+        catch ( ArtifactResolverException | DependencyResolverException | IOException e )
+        {
+            throw new MojoExecutionException( "Couldn't download artifact: " + e.getMessage(), e );
+        }
+    }
+
+    public void printClassesFromArtifactResult( ArtifactResult result )
+            throws IOException
+    {
+        JarFile jarFile = new JarFile( result.getArtifact().getFile() );
+        Enumeration e = jarFile.entries();
+
+        while ( e.hasMoreElements() )
+        {
+            JarEntry entry = ( JarEntry )e.nextElement();
+            String name = entry.getName();
+
+            // filter out files that do not end in .class
+            if ( name.length() <= 6 || !name.substring( name.length() - 6 ).equals( ".class" )) {
+                continue;
+            }
+
+            // remove .class from the end and change format to use periods instead of forward slashes
+            name = name.substring( 0, name.length() - 6 ).replace( '/', '.' );
+            getLog().info( name );
+        }
+        jarFile.close();
+    }
+
+    public ProjectBuildingRequest buildBuildingRequest()
+            throws MojoExecutionException, MojoFailureException
+    {
+        if ( coordinate.getArtifactId() == null && artifact == null )

Review comment:
       You don't use coordinate below. Are you missing an else clause? Is that the code that would run if someone used -DgroupId ... instead of -Dartifact?

##########
File path: src/test/java/org/apache/maven/plugins/dependency/TestGetClassesMojo.java
##########
@@ -0,0 +1,88 @@
+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 org.apache.maven.execution.MavenSession;
+import org.apache.maven.plugin.LegacySupport;
+import org.apache.maven.plugin.testing.stubs.MavenProjectStub;
+import org.apache.maven.settings.Server;
+import org.apache.maven.settings.Settings;
+import org.sonatype.aether.impl.internal.SimpleLocalRepositoryManager;
+import org.sonatype.aether.util.DefaultRepositorySystemSession;
+
+import java.io.File;
+
+public class TestGetClassesMojo
+        extends AbstractDependencyMojoTestCase
+{
+    GetClassesMojo mojo;
+
+    protected void setUp()
+            throws Exception
+    {
+        // required for mojo lookups to work
+        super.setUp( "markers", false );
+
+        File testPom = new File( getBasedir(), "target/test-classes/unit/get-test/plugin-config.xml" );
+        assert testPom.exists();
+        mojo = (GetClassesMojo) lookupMojo( "get-classes", testPom );
+
+        assertNotNull( mojo );
+
+        LegacySupport legacySupport = lookup( LegacySupport.class );
+        MavenSession session = newMavenSession( new MavenProjectStub() );
+        Settings settings = session.getSettings();
+        Server server = new Server();
+        server.setId( "myserver" );
+        server.setUsername( "foo" );
+        server.setPassword( "bar" );
+        settings.addServer( server );
+        legacySupport.setSession( session );
+        DefaultRepositorySystemSession repoSession =
+                (DefaultRepositorySystemSession) legacySupport.getRepositorySession();
+        repoSession.setLocalRepositoryManager( new SimpleLocalRepositoryManager( testDir.getAbsolutePath() ) );
+
+        setVariableValueToObject( mojo, "session", legacySupport.getSession() );
+    }
+
+    public void testGetClassesNotTransitive()
+            throws Exception
+    {
+        setVariableValueToObject( mojo, "remoteRepositories", "central::default::https://repo.maven.apache.org/maven2,"
+                + "central::::https://repo.maven.apache.org/maven2," + "https://repo.maven.apache.org/maven2" );
+        mojo.setArtifact("org.apache.commons:commons-lang3:3.6");
+        setVariableValueToObject( mojo, "transitive", Boolean.FALSE );
+
+        mojo.execute();
+        return;
+    }
+
+    public void testGetClassesTransitive()
+            throws Exception
+    {
+        setVariableValueToObject( mojo, "remoteRepositories", "central::default::https://repo.maven.apache.org/maven2,"
+                + "central::::https://repo.maven.apache.org/maven2," + "https://repo.maven.apache.org/maven2" );
+        mojo.setArtifact("org.apache.commons:commons-lang3:3.6");
+        setVariableValueToObject( mojo, "transitive", Boolean.TRUE );
+
+        mojo.execute();
+        return;

Review comment:
       No need for return.

##########
File path: src/main/java/org/apache/maven/plugins/dependency/GetClassesMojo.java
##########
@@ -0,0 +1,396 @@
+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;
+import org.codehaus.plexus.util.StringUtils;
+
+@Mojo( name = "get-classes", requiresProject = false, threadSafe = true )
+public class GetClassesMojo
+    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 groupId of the artifact to download. Ignored if {@link #artifact} is used.
+     */
+    @Parameter( property = "groupId" )
+    private String groupId;
+
+    /**
+     * The artifactId 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 url, separated by comma. ie.
+     * 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 = "true" )
+    private boolean transitive = true;
+
+    /**
+     * Skip plugin execution completely.
+     *
+     * @since 2.7
+     */
+    @Parameter( property = "mdep.skip", defaultValue = "false" )

Review comment:
       I think you can remove all of the 'skip' processing; it's not terribly useful for a mojo intended for CLI.

##########
File path: src/main/java/org/apache/maven/plugins/dependency/GetClassesMojo.java
##########
@@ -0,0 +1,396 @@
+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;
+import org.codehaus.plexus.util.StringUtils;
+
+@Mojo( name = "get-classes", requiresProject = false, threadSafe = true )
+public class GetClassesMojo
+    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 groupId of the artifact to download. Ignored if {@link #artifact} is used.
+     */
+    @Parameter( property = "groupId" )
+    private String groupId;
+
+    /**
+     * The artifactId 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 url, separated by comma. ie.
+     * 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 = "true" )
+    private boolean transitive = true;
+
+    /**
+     * Skip plugin execution completely.
+     *
+     * @since 2.7
+     */
+    @Parameter( property = "mdep.skip", defaultValue = "false" )
+    private boolean skip;
+
+    @Override
+    public void execute() throws MojoExecutionException, MojoFailureException
+    {
+        ProjectBuildingRequest buildingRequest = buildBuildingRequest();
+        DefaultDependableCoordinate coordinate = getCoordinate();
+
+        try
+        {
+            getLog().info( "Retrieving classes of dependencies for " + artifact );
+            if ( isTransitive() )
+            {
+                Iterable<ArtifactResult> artifacts = getDependencyResolver().resolveDependencies( buildingRequest, coordinate, null );
+
+                for ( ArtifactResult result : artifacts )
+                {
+                    printClassesFromArtifactResult( result );

Review comment:
       Print the file name of the jar before printing its contents if you are printing more than one jar file's worth?

##########
File path: src/test/java/org/apache/maven/plugins/dependency/TestGetClassesMojo.java
##########
@@ -0,0 +1,88 @@
+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 org.apache.maven.execution.MavenSession;
+import org.apache.maven.plugin.LegacySupport;
+import org.apache.maven.plugin.testing.stubs.MavenProjectStub;
+import org.apache.maven.settings.Server;
+import org.apache.maven.settings.Settings;
+import org.sonatype.aether.impl.internal.SimpleLocalRepositoryManager;
+import org.sonatype.aether.util.DefaultRepositorySystemSession;
+
+import java.io.File;
+
+public class TestGetClassesMojo
+        extends AbstractDependencyMojoTestCase
+{
+    GetClassesMojo mojo;
+
+    protected void setUp()
+            throws Exception
+    {
+        // required for mojo lookups to work
+        super.setUp( "markers", false );
+
+        File testPom = new File( getBasedir(), "target/test-classes/unit/get-test/plugin-config.xml" );
+        assert testPom.exists();
+        mojo = (GetClassesMojo) lookupMojo( "get-classes", testPom );
+
+        assertNotNull( mojo );
+
+        LegacySupport legacySupport = lookup( LegacySupport.class );
+        MavenSession session = newMavenSession( new MavenProjectStub() );
+        Settings settings = session.getSettings();
+        Server server = new Server();
+        server.setId( "myserver" );
+        server.setUsername( "foo" );
+        server.setPassword( "bar" );
+        settings.addServer( server );
+        legacySupport.setSession( session );
+        DefaultRepositorySystemSession repoSession =
+                (DefaultRepositorySystemSession) legacySupport.getRepositorySession();
+        repoSession.setLocalRepositoryManager( new SimpleLocalRepositoryManager( testDir.getAbsolutePath() ) );
+
+        setVariableValueToObject( mojo, "session", legacySupport.getSession() );
+    }
+
+    public void testGetClassesNotTransitive()
+            throws Exception
+    {
+        setVariableValueToObject( mojo, "remoteRepositories", "central::default::https://repo.maven.apache.org/maven2,"
+                + "central::::https://repo.maven.apache.org/maven2," + "https://repo.maven.apache.org/maven2" );
+        mojo.setArtifact("org.apache.commons:commons-lang3:3.6");
+        setVariableValueToObject( mojo, "transitive", Boolean.FALSE );
+
+        mojo.execute();
+        return;
+    }
+
+    public void testGetClassesTransitive()

Review comment:
       Um, this does not seem to test anything except that it does not explode.
   
   
   

##########
File path: src/main/java/org/apache/maven/plugins/dependency/GetClassesMojo.java
##########
@@ -0,0 +1,396 @@
+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;
+import org.codehaus.plexus.util.StringUtils;
+
+@Mojo( name = "get-classes", requiresProject = false, threadSafe = true )
+public class GetClassesMojo
+    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 groupId of the artifact to download. Ignored if {@link #artifact} is used.
+     */
+    @Parameter( property = "groupId" )
+    private String groupId;
+
+    /**
+     * The artifactId 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 url, separated by comma. ie.
+     * 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 = "true" )
+    private boolean transitive = true;
+
+    /**
+     * Skip plugin execution completely.
+     *
+     * @since 2.7
+     */
+    @Parameter( property = "mdep.skip", defaultValue = "false" )
+    private boolean skip;
+
+    @Override
+    public void execute() throws MojoExecutionException, MojoFailureException
+    {
+        ProjectBuildingRequest buildingRequest = buildBuildingRequest();
+        DefaultDependableCoordinate coordinate = getCoordinate();
+
+        try
+        {
+            getLog().info( "Retrieving classes of dependencies for " + artifact );
+            if ( isTransitive() )
+            {
+                Iterable<ArtifactResult> artifacts = getDependencyResolver().resolveDependencies( buildingRequest, coordinate, null );
+
+                for ( ArtifactResult result : artifacts )
+                {
+                    printClassesFromArtifactResult( result );
+                }
+            }
+            else
+            {
+                ArtifactResult result = getArtifactResolver().resolveArtifact( buildingRequest, toArtifactCoordinate( coordinate ) );
+
+                printClassesFromArtifactResult( result );
+            }
+        }
+        catch ( ArtifactResolverException | DependencyResolverException | IOException e )
+        {
+            throw new MojoExecutionException( "Couldn't download artifact: " + e.getMessage(), e );
+        }
+    }
+
+    public void printClassesFromArtifactResult( ArtifactResult result )
+            throws IOException
+    {
+        JarFile jarFile = new JarFile( result.getArtifact().getFile() );
+        Enumeration e = jarFile.entries();
+
+        while ( e.hasMoreElements() )
+        {
+            JarEntry entry = ( JarEntry )e.nextElement();
+            String name = entry.getName();
+
+            // filter out files that do not end in .class
+            if ( name.length() <= 6 || !name.substring( name.length() - 6 ).equals( ".class" )) {
+                continue;
+            }
+
+            // remove .class from the end and change format to use periods instead of forward slashes
+            name = name.substring( 0, name.length() - 6 ).replace( '/', '.' );
+            getLog().info( name );

Review comment:
       I don't think that using the log is the best delivery mechanism, but I could be confused. @elharo what do you think? Also, I have no idea how to test for log output, you'd need to mock the log somehow.

##########
File path: src/test/java/org/apache/maven/plugins/dependency/TestGetClassesMojo.java
##########
@@ -0,0 +1,88 @@
+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 org.apache.maven.execution.MavenSession;
+import org.apache.maven.plugin.LegacySupport;
+import org.apache.maven.plugin.testing.stubs.MavenProjectStub;
+import org.apache.maven.settings.Server;
+import org.apache.maven.settings.Settings;
+import org.sonatype.aether.impl.internal.SimpleLocalRepositoryManager;
+import org.sonatype.aether.util.DefaultRepositorySystemSession;
+
+import java.io.File;
+
+public class TestGetClassesMojo
+        extends AbstractDependencyMojoTestCase
+{
+    GetClassesMojo mojo;
+
+    protected void setUp()
+            throws Exception
+    {
+        // required for mojo lookups to work
+        super.setUp( "markers", false );
+
+        File testPom = new File( getBasedir(), "target/test-classes/unit/get-test/plugin-config.xml" );
+        assert testPom.exists();
+        mojo = (GetClassesMojo) lookupMojo( "get-classes", testPom );
+
+        assertNotNull( mojo );
+
+        LegacySupport legacySupport = lookup( LegacySupport.class );
+        MavenSession session = newMavenSession( new MavenProjectStub() );
+        Settings settings = session.getSettings();
+        Server server = new Server();
+        server.setId( "myserver" );
+        server.setUsername( "foo" );
+        server.setPassword( "bar" );
+        settings.addServer( server );
+        legacySupport.setSession( session );
+        DefaultRepositorySystemSession repoSession =
+                (DefaultRepositorySystemSession) legacySupport.getRepositorySession();
+        repoSession.setLocalRepositoryManager( new SimpleLocalRepositoryManager( testDir.getAbsolutePath() ) );
+
+        setVariableValueToObject( mojo, "session", legacySupport.getSession() );
+    }
+
+    public void testGetClassesNotTransitive()
+            throws Exception
+    {
+        setVariableValueToObject( mojo, "remoteRepositories", "central::default::https://repo.maven.apache.org/maven2,"
+                + "central::::https://repo.maven.apache.org/maven2," + "https://repo.maven.apache.org/maven2" );
+        mojo.setArtifact("org.apache.commons:commons-lang3:3.6");
+        setVariableValueToObject( mojo, "transitive", Boolean.FALSE );
+
+        mojo.execute();
+        return;

Review comment:
       No need for return.

##########
File path: src/main/java/org/apache/maven/plugins/dependency/GetClassesMojo.java
##########
@@ -0,0 +1,406 @@
+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;
+import org.codehaus.plexus.util.StringUtils;
+
+
+/**
+ * Retrieves and lists all class dependencies for the specified artifact from the specified remote repositories.
+ */
+@Mojo( name = "get-classes", requiresProject = false, threadSafe = true )
+public class GetClassesMojo
+    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 groupId of the artifact to download. Ignored if {@link #artifact} is used.
+     */
+    @Parameter( property = "groupId" )
+    private String groupId;
+
+    /**
+     * The artifactId 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";

Review comment:
       It will work for a .war or any other 'renamed jar'. But the substitution of dots and slashes should perhaps be removed for non-.jar.

##########
File path: src/test/java/org/apache/maven/plugins/dependency/TestGetClassesMojo.java
##########
@@ -0,0 +1,86 @@
+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 org.apache.maven.execution.MavenSession;
+import org.apache.maven.plugin.LegacySupport;
+import org.apache.maven.plugin.testing.stubs.MavenProjectStub;
+import org.apache.maven.settings.Server;
+import org.apache.maven.settings.Settings;
+import org.sonatype.aether.impl.internal.SimpleLocalRepositoryManager;

Review comment:
       Do you have an example to point at here?

##########
File path: src/test/java/org/apache/maven/plugins/dependency/TestGetClassesMojo.java
##########
@@ -0,0 +1,86 @@
+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 org.apache.maven.execution.MavenSession;
+import org.apache.maven.plugin.LegacySupport;
+import org.apache.maven.plugin.testing.stubs.MavenProjectStub;
+import org.apache.maven.settings.Server;
+import org.apache.maven.settings.Settings;
+import org.sonatype.aether.impl.internal.SimpleLocalRepositoryManager;
+import org.sonatype.aether.util.DefaultRepositorySystemSession;
+
+import java.io.File;
+
+public class TestGetClassesMojo
+        extends AbstractDependencyMojoTestCase
+{
+    GetClassesMojo mojo;
+
+    protected void setUp()
+            throws Exception
+    {
+        // required for mojo lookups to work
+        super.setUp( "markers", false );
+
+        File testPom = new File( getBasedir(), "target/test-classes/unit/get-test/plugin-config.xml" );
+        assert testPom.exists();

Review comment:
       oh, whoops, sorry I missed this.




----------------------------------------------------------------
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



[GitHub] [maven-dependency-plugin] jonvolfson commented on a change in pull request #57: [MDEP-645] Created new mojo GetClassesMojo which lists all class dependencies for a specified artifact.

Posted by GitBox <gi...@apache.org>.
jonvolfson commented on a change in pull request #57:
URL: https://github.com/apache/maven-dependency-plugin/pull/57#discussion_r441030376



##########
File path: src/main/java/org/apache/maven/plugins/dependency/GetClassesMojo.java
##########
@@ -0,0 +1,406 @@
+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;
+import org.codehaus.plexus.util.StringUtils;
+
+
+/**
+ * Retrieves and lists all class dependencies for the specified artifact from the specified remote repositories.
+ */
+@Mojo( name = "get-classes", requiresProject = false, threadSafe = true )
+public class GetClassesMojo
+    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 groupId of the artifact to download. Ignored if {@link #artifact} is used.
+     */
+    @Parameter( property = "groupId" )
+    private String groupId;
+
+    /**
+     * The artifactId 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 url, separated by comma. ie.
+     * 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 = "true" )
+    private boolean transitive = true;
+
+    /**
+     * Skip plugin execution completely.
+     *
+     * @since 2.7
+     */
+    @Parameter( property = "mdep.skip", defaultValue = "false" )
+    private boolean skip;
+
+    @Override
+    public void execute() throws MojoExecutionException, MojoFailureException
+    {
+        ProjectBuildingRequest buildingRequest = buildBuildingRequest();
+        DefaultDependableCoordinate coordinate = getCoordinate();
+
+        try
+        {
+            getLog().info( "Retrieving classes of dependencies for " + artifact );
+            if ( isTransitive() )
+            {
+                Iterable<ArtifactResult> artifacts = getDependencyResolver()
+                        .resolveDependencies( buildingRequest, coordinate, null );
+
+                for ( ArtifactResult result : artifacts )
+                {
+                    printClassesFromArtifactResult( result );
+                }
+            }
+            else
+            {
+                ArtifactResult result = getArtifactResolver()
+                        .resolveArtifact( buildingRequest, toArtifactCoordinate( coordinate ) );
+
+                printClassesFromArtifactResult( result );
+            }
+        }
+        catch ( ArtifactResolverException | DependencyResolverException | IOException e )
+        {
+            throw new MojoExecutionException( "Couldn't download artifact: " + e.getMessage(), e );
+        }
+    }
+
+    public void printClassesFromArtifactResult( ArtifactResult result )

Review comment:
       fixed

##########
File path: src/main/java/org/apache/maven/plugins/dependency/GetClassesMojo.java
##########
@@ -0,0 +1,406 @@
+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;
+import org.codehaus.plexus.util.StringUtils;
+
+
+/**
+ * Retrieves and lists all class dependencies for the specified artifact from the specified remote repositories.
+ */
+@Mojo( name = "get-classes", requiresProject = false, threadSafe = true )
+public class GetClassesMojo
+    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 groupId of the artifact to download. Ignored if {@link #artifact} is used.
+     */
+    @Parameter( property = "groupId" )
+    private String groupId;
+
+    /**
+     * The artifactId 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 url, separated by comma. ie.
+     * 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 = "true" )
+    private boolean transitive = true;
+
+    /**
+     * Skip plugin execution completely.
+     *
+     * @since 2.7
+     */
+    @Parameter( property = "mdep.skip", defaultValue = "false" )
+    private boolean skip;
+
+    @Override
+    public void execute() throws MojoExecutionException, MojoFailureException
+    {
+        ProjectBuildingRequest buildingRequest = buildBuildingRequest();
+        DefaultDependableCoordinate coordinate = getCoordinate();
+
+        try
+        {
+            getLog().info( "Retrieving classes of dependencies for " + artifact );
+            if ( isTransitive() )
+            {
+                Iterable<ArtifactResult> artifacts = getDependencyResolver()
+                        .resolveDependencies( buildingRequest, coordinate, null );
+
+                for ( ArtifactResult result : artifacts )
+                {
+                    printClassesFromArtifactResult( result );
+                }
+            }
+            else
+            {
+                ArtifactResult result = getArtifactResolver()
+                        .resolveArtifact( buildingRequest, toArtifactCoordinate( coordinate ) );
+
+                printClassesFromArtifactResult( result );
+            }
+        }
+        catch ( ArtifactResolverException | DependencyResolverException | IOException e )
+        {
+            throw new MojoExecutionException( "Couldn't download artifact: " + e.getMessage(), e );
+        }
+    }
+
+    public void printClassesFromArtifactResult( ArtifactResult result )
+            throws IOException
+    {
+        JarFile jarFile = new JarFile( result.getArtifact().getFile() );
+        Enumeration e = jarFile.entries();
+
+        while ( e.hasMoreElements() )
+        {
+            JarEntry entry = (JarEntry) e.nextElement();
+            String name = entry.getName();
+
+            // filter out files that do not end in .class
+            if ( name.length() <= 6 || !name.substring( name.length() - 6 ).equals( ".class" ) )
+            {
+                continue;
+            }
+
+            // remove .class from the end and change format to use periods instead of forward slashes
+            name = name.substring( 0, name.length() - 6 ).replace( '/', '.' );
+            getLog().info( name );
+        }
+        jarFile.close();
+    }
+
+    public ProjectBuildingRequest buildBuildingRequest()

Review comment:
       fixed




----------------------------------------------------------------
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



[GitHub] [maven-dependency-plugin] jonvolfson commented on a change in pull request #57: [MDEP-645] Created new mojo GetClassesMojo which lists all class dependencies for a specified artifact.

Posted by GitBox <gi...@apache.org>.
jonvolfson commented on a change in pull request #57:
URL: https://github.com/apache/maven-dependency-plugin/pull/57#discussion_r431270700



##########
File path: src/main/java/org/apache/maven/plugins/dependency/ListClassesMojo.java
##########
@@ -0,0 +1,402 @@
+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();

Review comment:
       I do not as well. This was taken from the GetMojo. It seems this class is needed in order to properly use the artifact/dependency resolver when retrieving the specified artifact as DefaultArtifactCoordinate creates new problems.




----------------------------------------------------------------
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



[GitHub] [maven-dependency-plugin] jonvolfson commented on a change in pull request #57: [MDEP-645] Created new mojo GetClassesMojo which lists all class dependencies for a specified artifact.

Posted by GitBox <gi...@apache.org>.
jonvolfson commented on a change in pull request #57:
URL: https://github.com/apache/maven-dependency-plugin/pull/57#discussion_r431382426



##########
File path: src/main/java/org/apache/maven/plugins/dependency/ListClassesMojo.java
##########
@@ -0,0 +1,391 @@
+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.
+     *

Review comment:
       fixed

##########
File path: src/main/java/org/apache/maven/plugins/dependency/ListClassesMojo.java
##########
@@ -0,0 +1,391 @@
+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 ( isTransitive() )
+            {
+                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 " + artifact + ": " + e.getMessage(), e );
+        }
+    }
+
+    private void printClassesFromArtifactResult( ArtifactResult result )
+            throws IOException
+    {
+        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 );
+        }
+        jarFile.close();

Review comment:
       fixed

##########
File path: src/main/java/org/apache/maven/plugins/dependency/ListClassesMojo.java
##########
@@ -0,0 +1,391 @@
+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 ( isTransitive() )
+            {
+                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 " + artifact + ": " + e.getMessage(), e );
+        }
+    }
+
+    private void printClassesFromArtifactResult( ArtifactResult result )
+            throws IOException
+    {
+        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 );
+        }
+        jarFile.close();
+    }
+
+    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 )
+    {
+        ArtifactHandler artifactHandler = artifactHandlerManager.getArtifactHandler( dependableCoordinate.getType() );
+        DefaultArtifactCoordinate artifactCoordinate = new DefaultArtifactCoordinate();
+        artifactCoordinate.setGroupId( dependableCoordinate.getGroupId() );
+        artifactCoordinate.setArtifactId( dependableCoordinate.getArtifactId() );
+        artifactCoordinate.setVersion( dependableCoordinate.getVersion() );
+        artifactCoordinate.setClassifier( dependableCoordinate.getClassifier() );
+        artifactCoordinate.setExtension( artifactHandler.getExtension() );
+        return artifactCoordinate;
+    }
+
+    ArtifactRepository parseRepository( String repo, ArtifactRepositoryPolicy policy )
+            throws MojoFailureException
+    {
+        // if it's a simple url
+        String id = "temp";
+        ArtifactRepositoryLayout layout = getLayout( "default" );
+
+        // if it's an extended repo URL of the form id::layout::url
+        if ( repo.contains( "::" ) )
+        {
+            Matcher matcher = ALT_REPO_SYNTAX_PATTERN.matcher( repo );
+            if ( !matcher.matches() )
+            {
+                throw new MojoFailureException( repo, "Invalid syntax for repository: " + repo,
+                        "Invalid syntax for repository. Use \"id::layout::url\" or \"URL\"." );
+            }
+
+            id = matcher.group( 1 ).trim();
+            if ( !( matcher.group( 2 ) == null || matcher.group( 2 ).trim().isEmpty() ) )
+            {
+                layout = getLayout( matcher.group( 2 ).trim() );
+            }
+            repo = matcher.group( 3 ).trim();
+        }
+        return new MavenArtifactRepository( id, repo, layout, policy, policy );
+    }
+
+    private ArtifactRepositoryLayout getLayout( String id )
+            throws MojoFailureException
+    {
+        ArtifactRepositoryLayout layout = repositoryLayouts.get( id );
+
+        if ( layout == null )
+        {
+            throw new MojoFailureException( id, "Invalid repository layout", "Invalid repository layout: " + id );
+        }
+
+        return layout;
+    }
+
+    /**
+     * @return {@link #skip}

Review comment:
       fixed

##########
File path: src/test/java/org/apache/maven/plugins/dependency/TestGetClassesMojo.java
##########
@@ -0,0 +1,87 @@
+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 org.apache.maven.execution.MavenSession;
+import org.apache.maven.plugin.LegacySupport;
+import org.apache.maven.plugin.testing.stubs.MavenProjectStub;
+import org.apache.maven.settings.Server;
+import org.apache.maven.settings.Settings;
+import org.junit.Assert;
+import org.sonatype.aether.impl.internal.SimpleLocalRepositoryManager;
+import org.sonatype.aether.util.DefaultRepositorySystemSession;
+
+import java.io.File;
+
+public class TestGetClassesMojo
+        extends AbstractDependencyMojoTestCase
+{
+    ListClassesMojo mojo;

Review comment:
       fixed




----------------------------------------------------------------
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



[GitHub] [maven-dependency-plugin] jonvolfson commented on a change in pull request #57: [MDEP-645] Created new mojo GetClassesMojo which lists all class dependencies for a specified artifact.

Posted by GitBox <gi...@apache.org>.
jonvolfson commented on a change in pull request #57:
URL: https://github.com/apache/maven-dependency-plugin/pull/57#discussion_r441029746



##########
File path: src/main/java/org/apache/maven/plugins/dependency/GetClassesMojo.java
##########
@@ -0,0 +1,406 @@
+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;
+import org.codehaus.plexus.util.StringUtils;
+
+
+/**
+ * Retrieves and lists all class dependencies for the specified artifact from the specified remote repositories.
+ */
+@Mojo( name = "get-classes", requiresProject = false, threadSafe = true )
+public class GetClassesMojo
+    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 groupId of the artifact to download. Ignored if {@link #artifact} is used.
+     */
+    @Parameter( property = "groupId" )
+    private String groupId;
+
+    /**
+     * The artifactId 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 url, separated by comma. ie.
+     * 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 = "true" )
+    private boolean transitive = true;
+
+    /**
+     * Skip plugin execution completely.
+     *
+     * @since 2.7
+     */
+    @Parameter( property = "mdep.skip", defaultValue = "false" )
+    private boolean skip;
+
+    @Override
+    public void execute() throws MojoExecutionException, MojoFailureException
+    {
+        ProjectBuildingRequest buildingRequest = buildBuildingRequest();
+        DefaultDependableCoordinate coordinate = getCoordinate();
+
+        try
+        {
+            getLog().info( "Retrieving classes of dependencies for " + artifact );

Review comment:
       fixed, forgot to comment




----------------------------------------------------------------
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



[GitHub] [maven-dependency-plugin] jonvolfson commented on a change in pull request #57: [MDEP-645] Created new mojo GetClassesMojo which lists all class dependencies for a specified artifact.

Posted by GitBox <gi...@apache.org>.
jonvolfson commented on a change in pull request #57:
URL: https://github.com/apache/maven-dependency-plugin/pull/57#discussion_r441029129



##########
File path: src/main/java/org/apache/maven/plugins/dependency/GetClassesMojo.java
##########
@@ -0,0 +1,406 @@
+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;
+import org.codehaus.plexus.util.StringUtils;
+
+
+/**
+ * Retrieves and lists all class dependencies for the specified artifact from the specified remote repositories.
+ */
+@Mojo( name = "get-classes", requiresProject = false, threadSafe = true )
+public class GetClassesMojo
+    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 groupId of the artifact to download. Ignored if {@link #artifact} is used.
+     */
+    @Parameter( property = "groupId" )
+    private String groupId;
+
+    /**
+     * The artifactId 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 url, separated by comma. ie.

Review comment:
       fixed, forgot to comment




----------------------------------------------------------------
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



[GitHub] [maven-dependency-plugin] jonvolfson commented on a change in pull request #57: [MDEP-645] Created new mojo GetClassesMojo which lists all class dependencies for a specified artifact.

Posted by GitBox <gi...@apache.org>.
jonvolfson commented on a change in pull request #57:
URL: https://github.com/apache/maven-dependency-plugin/pull/57#discussion_r431277735



##########
File path: src/main/java/org/apache/maven/plugins/dependency/ListClassesMojo.java
##########
@@ -0,0 +1,402 @@
+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. ie.
+     * 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 = buildBuildingRequest();
+        DefaultDependableCoordinate coordinate = getCoordinate();

Review comment:
       fixed




----------------------------------------------------------------
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



[GitHub] [maven-dependency-plugin] jonvolfson commented on pull request #57: [MDEP-645] Created new mojo GetClassesMojo which lists all class dependencies for a specified artifact.

Posted by GitBox <gi...@apache.org>.
jonvolfson commented on pull request #57:
URL: https://github.com/apache/maven-dependency-plugin/pull/57#issuecomment-634103391


   Updated PR title. This is a fix for MDEP-645


----------------------------------------------------------------
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



[GitHub] [maven-dependency-plugin] jonvolfson commented on a change in pull request #57: [MDEP-645] Created new mojo GetClassesMojo which lists all class dependencies for a specified artifact.

Posted by GitBox <gi...@apache.org>.
jonvolfson commented on a change in pull request #57:
URL: https://github.com/apache/maven-dependency-plugin/pull/57#discussion_r431379203



##########
File path: src/main/java/org/apache/maven/plugins/dependency/ListClassesMojo.java
##########
@@ -0,0 +1,391 @@
+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 ( isTransitive() )
+            {
+                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 " + artifact + ": " + e.getMessage(), e );

Review comment:
       I believe the original message was correct before I changed it to include artifact. If a transitive dependency wasn't able to be resolved, e.getMessage() should have included the correct one.




----------------------------------------------------------------
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