You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by sl...@apache.org on 2020/12/26 16:15:01 UTC

[maven-artifact-transfer] branch MSHARED-801v3 created (now 1dc0c33)

This is an automated email from the ASF dual-hosted git repository.

slachiewicz pushed a change to branch MSHARED-801v3
in repository https://gitbox.apache.org/repos/asf/maven-artifact-transfer.git.


      at 1dc0c33  [MSHARED-801] Add functionality to collect raw dependencies in Maven 3+

This branch includes the following new commits:

     new 1dc0c33  [MSHARED-801] Add functionality to collect raw dependencies in Maven 3+

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



[maven-artifact-transfer] 01/01: [MSHARED-801] Add functionality to collect raw dependencies in Maven 3+

Posted by sl...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

slachiewicz pushed a commit to branch MSHARED-801v3
in repository https://gitbox.apache.org/repos/asf/maven-artifact-transfer.git

commit 1dc0c339ef33c600318e83b5f4d643d36ee5d3fb
Author: Sylwester Lachiewicz <sl...@apache.org>
AuthorDate: Sat Dec 26 17:14:48 2020 +0100

    [MSHARED-801] Add functionality to collect raw dependencies in Maven 3+
    
    Simplified version from Gabriel Belingueres - based only Maven 3.1 API
---
 pom.xml                                            |   6 +
 .../collector/DependencyCollectorMojo.java         |  59 +++-
 .../collector/DependencyCollectorTest.java         | 333 ++++++++++++++++++++-
 .../src/test/projects/managedDepsAndScope/pom.xml  |  68 +++++
 .../src/test/projects/mockDependencies/a10/pom.xml |  34 +++
 .../src/test/projects/mockDependencies/b10/pom.xml |  33 ++
 .../src/test/projects/mockDependencies/c10/pom.xml |  33 ++
 .../src/test/projects/mockDependencies/d10/pom.xml |  34 +++
 .../src/test/projects/mockDependencies/pom.xml     |  37 +++
 .../src/test/projects/mockDependencies/t10/pom.xml |  25 ++
 .../src/test/projects/mockDependencies/t11/pom.xml |  33 ++
 .../src/test/projects/mockDependencies/u10/pom.xml |  25 ++
 .../src/test/projects/mockDependencies/u11/pom.xml |  25 ++
 .../src/test/projects/noExcludedDep/pom.xml        |  68 +++++
 .../src/test/projects/noRepeatedDeps/pom.xml       |  62 ++++
 .../test/projects/noTransitiveOptionalDep/pom.xml  |  57 ++++
 .../src/test/projects/noTransitiveTestDep/pom.xml  |  63 ++++
 .../src/test/projects/optionalDep/pom.xml          |  59 ++++
 .../src/test/projects/transitiveTestDeps/pom.xml   |  58 ++++
 .../src/test/projects/versionConstraintDep/pom.xml |  57 ++++
 .../dependencies/collect/CollectorResult.java      |   6 +
 .../dependencies/collect/DependencyCollector.java  |  34 +++
 .../internal/DefaultDependencyCollector.java       |  24 ++
 .../collect/internal/Maven31CollectorResult.java   |  67 +++++
 .../internal/Maven31DependencyCollector.java       | 115 +++++++
 .../Maven31DirectScopeDependencySelector.java      | 121 ++++++++
 .../collect/internal/MavenDependencyCollector.java |   9 +
 27 files changed, 1520 insertions(+), 25 deletions(-)

diff --git a/pom.xml b/pom.xml
index 5dce620..cf62d8c 100644
--- a/pom.xml
+++ b/pom.xml
@@ -174,6 +174,12 @@
     </dependency>
 
     <dependency>
+      <groupId>org.apache.maven.shared</groupId>
+      <artifactId>maven-dependency-tree</artifactId>
+      <version>3.0.1</version>
+    </dependency>
+
+    <dependency>
       <groupId>org.codehaus.plexus</groupId>
       <artifactId>plexus-component-annotations</artifactId>
     </dependency>
diff --git a/src/it/maven-dependency-collector-plugin/src/main/java/org/apache/maven/plugin/dependency/collector/DependencyCollectorMojo.java b/src/it/maven-dependency-collector-plugin/src/main/java/org/apache/maven/plugin/dependency/collector/DependencyCollectorMojo.java
index eb74bdb..40601e6 100644
--- a/src/it/maven-dependency-collector-plugin/src/main/java/org/apache/maven/plugin/dependency/collector/DependencyCollectorMojo.java
+++ b/src/it/maven-dependency-collector-plugin/src/main/java/org/apache/maven/plugin/dependency/collector/DependencyCollectorMojo.java
@@ -1,4 +1,4 @@
-package org.apache.maven.plugin.artifact.installer;
+package org.apache.maven.plugin.dependency.collector;
 
 /*
  * Licensed to the Apache Software Foundation (ASF) under one
@@ -19,7 +19,16 @@ package org.apache.maven.plugin.artifact.installer;
  * under the License.
  */
 
+import java.io.File;
+import java.io.IOException;
+import java.io.StringWriter;
+import java.nio.charset.Charset;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.util.Arrays;
+import java.util.List;
 
+import org.apache.maven.artifact.repository.ArtifactRepository;
 import org.apache.maven.execution.MavenSession;
 import org.apache.maven.plugin.AbstractMojo;
 import org.apache.maven.plugin.MojoExecutionException;
@@ -28,15 +37,25 @@ import org.apache.maven.plugins.annotations.Component;
 import org.apache.maven.plugins.annotations.LifecyclePhase;
 import org.apache.maven.plugins.annotations.Mojo;
 import org.apache.maven.plugins.annotations.Parameter;
-import org.apache.maven.model.Model;
+import org.apache.maven.project.DefaultProjectBuildingRequest;
+import org.apache.maven.project.MavenProject;
 import org.apache.maven.project.ProjectBuildingRequest;
-import org.apache.maven.shared.transfer.collection.DependencyCollector;
-import org.apache.maven.shared.transfer.collection.DependencyCollectionException;
+import org.apache.maven.shared.dependency.graph.DependencyNode;
+import org.apache.maven.shared.dependency.graph.traversal.SerializingDependencyNodeVisitor;
+import org.apache.maven.shared.transfer.dependencies.collect.CollectorResult;
+import org.apache.maven.shared.transfer.dependencies.collect.DependencyCollector;
+import org.apache.maven.shared.transfer.dependencies.collect.DependencyCollectorException;
+import org.apache.maven.shared.transfer.project.NoFileAssignedException;
+import org.apache.maven.shared.transfer.project.deploy.ProjectDeployer;
+import org.apache.maven.shared.transfer.project.deploy.ProjectDeployerRequest;
+import org.apache.maven.shared.transfer.project.install.ProjectInstaller;
 
 /**
- * This mojo is implemented to test the DependencyCollector part of the maven-artifact-transfer shared component.
+ * This mojo is implemented to test the {@link DependencyCollector} part of the maven-artifact-transfer shared component.
+ *
+ * @author Gabriel Belingueres
  */
-@Mojo( name = "dependency-collector", defaultPhase = LifecyclePhase.VERIFY, threadSafe = true )
+@Mojo( name = "dependency-collector", defaultPhase = LifecyclePhase.VALIDATE, threadSafe = true )
 public class DependencyCollectorMojo
     extends AbstractMojo
 {
@@ -50,27 +69,41 @@ public class DependencyCollectorMojo
     @Parameter( defaultValue = "${session}", required = true, readonly = true )
     protected MavenSession session;
 
+    @Parameter( defaultValue = "${project}", required = true, readonly = true )
+    protected MavenProject project;
+
     @Component
-    private DependencyCollector collector;
+    private DependencyCollector dependencyCollector;
 
     public void execute()
         throws MojoExecutionException, MojoFailureException
     {
         getLog().info( "Hello from dependency-collector plugin" );
-        collectDependencies( session.getProjectBuildingRequest(), session.getCurrentProject().getModel() );
+
+        ProjectBuildingRequest buildingRequest =
+            new DefaultProjectBuildingRequest( session.getProjectBuildingRequest() );
+        buildingRequest.setProject( project );
+
+        collectDependencies( buildingRequest );
         getLog().info( "Bye bye from dependency-collector plugin" );
     }
 
-    private void collectDependencies( ProjectBuildingRequest projectBuildingRequest, Model model )
-        throws MojoFailureException, MojoExecutionException
+    private void collectDependencies( ProjectBuildingRequest buildingRequest ) throws MojoExecutionException
     {
         try
         {
-            collector.collectDependencies( projectBuildingRequest, model );
+            CollectorResult result = dependencyCollector.collectDependenciesGraph( buildingRequest, project.getModel() );
+            DependencyNode root = result.getDependencyGraphRoot();
+
+            StringWriter writer = new StringWriter();
+            SerializingDependencyNodeVisitor visitor = new SerializingDependencyNodeVisitor( writer );
+            root.accept( visitor );
+
+            getLog().info( writer.toString() );
         }
-        catch ( DependencyCollectionException e )
+        catch ( DependencyCollectorException e )
         {
-            throw new MojoExecutionException( "DependencyCollectionException", e );
+            throw new MojoExecutionException( "DependencyCollectorException", e );
         }
     }
 
diff --git a/src/it/maven-dependency-collector-plugin/src/test/java/org/apache/maven/plugin/dependency/collector/DependencyCollectorTest.java b/src/it/maven-dependency-collector-plugin/src/test/java/org/apache/maven/plugin/dependency/collector/DependencyCollectorTest.java
index b574683..9d844f5 100644
--- a/src/it/maven-dependency-collector-plugin/src/test/java/org/apache/maven/plugin/dependency/collector/DependencyCollectorTest.java
+++ b/src/it/maven-dependency-collector-plugin/src/test/java/org/apache/maven/plugin/dependency/collector/DependencyCollectorTest.java
@@ -19,16 +19,21 @@ package org.apache.maven.plugin.dependency.collector;
  * under the License.
  */
 
-import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertTrue;
 
 import java.io.File;
+import java.io.IOException;
 
+import org.codehaus.plexus.util.FileUtils;
+import org.junit.Assume;
+import org.junit.Before;
 import org.junit.Rule;
 import org.junit.Test;
+import org.junit.rules.TestName;
 import org.junit.runner.RunWith;
 
 import io.takari.maven.testing.TestResources;
+import io.takari.maven.testing.executor.MavenExecution;
 import io.takari.maven.testing.executor.MavenExecutionResult;
 import io.takari.maven.testing.executor.MavenRuntime;
 import io.takari.maven.testing.executor.MavenRuntime.MavenRuntimeBuilder;
@@ -36,34 +41,111 @@ import io.takari.maven.testing.executor.MavenVersions;
 import io.takari.maven.testing.executor.junit.MavenJUnitTestRunner;
 
 /**
- * This will check if the DependencyCollector works for all Maven versions 3.1.1, 3.2.5, 3.3.1, 3.3.9, 3.5.0,
- * 3.5.4, 3.6.3. This is done by using the test plugin <code>maven-artifact-installer-plugin</code> which uses the
- * ArtifactInstaller as component. By using this way we get a real runtime environment which supports all Maven
- * versions.
+ * This will check if the DependencyCollector works for all Maven versions 3.1.1, 3.2.5, 3.3.1, 3.3.9, 3.5.0, 3.5.2,
+ * 3.5.3, 3.5.4, 3.6.3. This is done by using the test plugin <code>maven-dependency-collector-plugin</code> which uses the
+ * DependencyCollector as component. By using this way we get a real runtime environment which supports all Maven versions.
  * 
- * @author Karl Heinz Marbaise
+ * @author Gabriel Belingueres
  */
 @RunWith( MavenJUnitTestRunner.class )
-@MavenVersions( { "3.1.1", "3.2.5", "3.3.9", "3.5.4", "3.6.3" } )
+@MavenVersions( {
+    // (Maven version) <-- uses (Aether version)
+    // test ONLY with the most recent Maven versions that make use of an specific Aether version.
+    "3.1.1", // <-- Eclipse Aether 0.9.0M2
+    
+//    "3.2.1", // <-- Eclipse Aether 0.9.0M2
+//    "3.2.2", // <-- Eclipse Aether 0.9.0M2
+    "3.2.3", // <-- Eclipse Aether 0.9.0M2
+    "3.2.5", // <-- Eclipse Aether 1.0.0.v20140518
+    
+//    "3.3.1", // <-- Eclipse Aether 1.0.2.v20150114 
+//    "3.3.3", // <-- Eclipse Aether 1.0.2.v20150114 
+    "3.3.9", // <-- Eclipse Aether 1.0.2.v20150114
+    
+    "3.5.0", // <-- Maven Resolver 1.0.3
+    "3.5.2", // <-- Maven Resolver 1.1.0
+//    "3.5.3", // <-- Maven Resolver 1.1.1
+    "3.5.4", // <-- Maven Resolver 1.1.1
+    "3.6.0",  // <-- Maven Resolver 1.3.1
+    "3.6.1",  // <-- Maven Resolver 1.3.3
+//    "3.6.2"  // <-- Maven Resolver 1.4.1
+    "3.6.3"  // <-- Maven Resolver 1.4.1
+} )
 public class DependencyCollectorTest
 {
+    private static final String LS = System.lineSeparator();
+    
+    private static boolean testDependenciesInstalled = false;
 
     @Rule
     public final TestResources resources = new TestResources();
 
+    /**
+     * Relates test method name with the project to test below "projects" directory.
+     */
+    @Rule
+    public final TestName testName = new TestName();
+    
     public final MavenRuntime mavenRuntime;
 
+    private File basedir;
+    
+    private MavenExecution mavenExecution;
+    
     public DependencyCollectorTest( MavenRuntimeBuilder builder )
         throws Exception
     {
         this.mavenRuntime = builder.build();
     }
+    
+    @Before
+    public void setUp()
+        throws Exception
+    {
+        installMockDependencies();
+        
+        String testMethodName = removeMavenVersion( testName.getMethodName() );
+        
+        basedir = resources.getBasedir( testMethodName );
 
-    @Test
-    public void buildExample()
+        //@formatter:off
+        mavenExecution = mavenRuntime
+            .forProject( basedir )
+            .withCliOption( "-DmvnVersion=" + mavenRuntime.getMavenVersion() ) // Might be superfluous
+            .withCliOption( "-B" )
+            .withCliOption( "-V" );
+        //@formatter:on
+    }
+    
+    /**
+     * Test method cames in the form "testMethod>[version]", so remove the method name only.
+     * @param methodWithMavenVersion the JUnit test method.
+     * @return the method without the maven version.
+     */
+    private String removeMavenVersion( String methodWithMavenVersion )
+    {
+        int index = methodWithMavenVersion.indexOf( '[' );
+        return methodWithMavenVersion.substring( 0, index );
+    }
+
+    /**
+     * Install dependencies used for testing.
+     * 
+     * workaround to install the dependencies used in the tests, since
+     * mavenRuntime is not static and it is required to install them and 
+     * it needs to execute just once.
+     * TODO: improve this or find a solution to use mrm-maven-plugin with
+     * takari
+     * 
+     * @throws Exception if anything goes wrong.
+     */
+    private void installMockDependencies()
         throws Exception
     {
-        File basedir = resources.getBasedir( "example" );
+        if ( testDependenciesInstalled )
+            return;
+
+        File basedir = resources.getBasedir( "mockDependencies" );
         //@formatter:off
         MavenExecutionResult result =
             mavenRuntime
@@ -71,14 +153,241 @@ public class DependencyCollectorTest
                 .withCliOption( "-DmvnVersion=" + mavenRuntime.getMavenVersion() ) // Might be superfluous
                 .withCliOption( "-B" )
                 .withCliOption( "-V" )
-                .execute( "clean", "verify" );
+                // We use verify to prevent running maven-install-plugin.
+                .execute( "clean", "install" );
         //@formatter:on
 
         result.assertErrorFreeLog();
+
+        testDependenciesInstalled = true;
+    }
+
+    /**
+     * collect dependencies, not informing the test dependencies from transitive dependencies.
+     * @throws Exception if anything goes wrong.
+     */
+    @Test
+    public void noTransitiveTestDep()
+        throws Exception
+    {
+        MavenExecutionResult result = mavenExecution.execute( "clean", "validate" );
+
+        result.assertErrorFreeLog();
+
+        // Check that the current plugins has been called at least once.
+        result.assertLogText( "[INFO] --- maven-dependency-collector-plugin:1.0.0:dependency-collector (id-dependency-collector) @ maven-dependency-collector-plugin-it ---" );
+
+        File logFile = new File(basedir, "log.txt");
+        String strLog = FileUtils.fileRead( logFile );
+        
+        String expected = 
+            "PROJECT-DEPENDENCY-COLLECTOR:maven-dependency-collector-plugin-it:jar:1.0.0-A:" + LS + 
+            "   org.apache.maven.plugin.dependency.collector.its:a:jar:1.0:compile" + LS +
+            "   org.apache.maven.plugin.dependency.collector.its:u:jar:1.0:test" + LS +
+            LS;
+
+        assertTrue( strLog.contains( expected ) );
+    }
+
+    /**
+     * collect dependencies, but don't inform in the tree those dependencies that are already shown in
+     * a a level closer to the root.
+     * @throws Exception if anything goes wrong.
+     */
+    @Test
+    public void noRepeatedDeps()
+        throws Exception
+    {
+        MavenExecutionResult result = mavenExecution.execute( "clean", "validate" );
+
+        result.assertErrorFreeLog();
+
+        // Check that the current plugins has been called at least once.
+        result.assertLogText( "[INFO] --- maven-dependency-collector-plugin:1.0.0:dependency-collector (id-dependency-collector) @ maven-dependency-collector-plugin-it ---" );
+
+        File logFile = new File(basedir, "log.txt");
+        String strLog = FileUtils.fileRead( logFile );
+        
+        String expected = 
+            "PROJECT-DEPENDENCY-COLLECTOR:maven-dependency-collector-plugin-it:jar:1.0.0-A:" + LS +
+            "   org.apache.maven.plugin.dependency.collector.its:c:jar:1.0:compile" + LS +
+            "      org.apache.maven.plugin.dependency.collector.its:b:jar:1.0:compile" + LS +
+            "   org.apache.maven.plugin.dependency.collector.its:b:jar:1.0:compile" + LS +
+            "      org.apache.maven.plugin.dependency.collector.its:a:jar:1.0:compile" + LS +
+            LS;
+
+        assertTrue( strLog.contains( expected ) );
+    }
+
+    /**
+     * collect test dependencies, and its respective compile scope dependencies are informed as "test" scope
+     * for the project. 
+     * @throws Exception if anything goes wrong.
+     */
+    @Test
+    public void transitiveTestDeps()
+        throws Exception
+    {
+        MavenExecutionResult result = mavenExecution.execute( "clean", "validate" );
+
+        result.assertErrorFreeLog();
+
+        // Check that the current plugins has been called at least once.
+        result.assertLogText( "[INFO] --- maven-dependency-collector-plugin:1.0.0:dependency-collector (id-dependency-collector) @ maven-dependency-collector-plugin-it ---" );
+
+        File logFile = new File(basedir, "log.txt");
+        String strLog = FileUtils.fileRead( logFile );
+        
+        String expected = 
+            "PROJECT-DEPENDENCY-COLLECTOR:maven-dependency-collector-plugin-it:jar:1.0.0-A:" + LS +
+            "   org.apache.maven.plugin.dependency.collector.its:t:jar:1.1:test" + LS +
+            "      org.apache.maven.plugin.dependency.collector.its:u:jar:1.0:test" + LS +
+            LS;
+
+        assertTrue( strLog.contains( expected ) );
+    }
+
+    /**
+     * collect dependencies, and inform when dependencyManagement supersedes 
+     * the declared (premanaged) version and scope.
+     * @throws Exception if anything goes wrong.
+     */
+    @Test
+    public void managedDepsAndScope()
+        throws Exception
+    {
+        MavenExecutionResult result = mavenExecution.execute( "clean", "validate" );
+
+        result.assertErrorFreeLog();
+
+        // Check that the current plugins has been called at least once.
+        result.assertLogText( "[INFO] --- maven-dependency-collector-plugin:1.0.0:dependency-collector (id-dependency-collector) @ maven-dependency-collector-plugin-it ---" );
+
+        File logFile = new File(basedir, "log.txt");
+        String strLog = FileUtils.fileRead( logFile );
+        
+        String expected = 
+            "PROJECT-DEPENDENCY-COLLECTOR:maven-dependency-collector-plugin-it:jar:1.0.0-A:" + LS +
+            "   org.apache.maven.plugin.dependency.collector.its:t:jar:1.1:compile" + LS +
+            "      org.apache.maven.plugin.dependency.collector.its:u:jar:1.1:test (version managed from 1.0; scope managed from compile)" + LS +
+            LS;
+
+        assertTrue( strLog.contains( expected ) );
+    }
+
+    /**
+     * collect dependencies, and inform when a dependency is optional.
+     * NOTE: Maven 3.0.x and 3.1+ behave differently. 
+     * @throws Exception if anything goes wrong.
+     */
+    @Test
+    public void optionalDep()
+        throws Exception
+    {
+        MavenExecutionResult result = mavenExecution.execute( "clean", "validate" );
+
+        result.assertErrorFreeLog();
+
+        // Check that the current plugins has been called at least once.
+        result.assertLogText( "[INFO] --- maven-dependency-collector-plugin:1.0.0:dependency-collector (id-dependency-collector) @ maven-dependency-collector-plugin-it ---" );
+
+        File logFile = new File(basedir, "log.txt");
+        String strLog = FileUtils.fileRead( logFile );
+
+        String expected =
+                "PROJECT-DEPENDENCY-COLLECTOR:maven-dependency-collector-plugin-it:jar:1.0.0-A:" + LS +
+                "   org.apache.maven.plugin.dependency.collector.its:c:jar:1.0:runtime (optional) " + LS + 
+                "      org.apache.maven.plugin.dependency.collector.its:b:jar:1.0:runtime (optional) " + LS + 
+                "         org.apache.maven.plugin.dependency.collector.its:a:jar:1.0:runtime (optional) " + LS + 
+                LS;
+// Maven 3.0.x
+//          expected =
+//              "PROJECT-DEPENDENCY-COLLECTOR:maven-dependency-collector-plugin-it:jar:1.0.0-A:" + LS +
+//              "   org.apache.maven.plugin.dependency.collector.its:c:jar:1.0:runtime (optional) " + LS +
+//              "      org.apache.maven.plugin.dependency.collector.its:b:jar:1.0:runtime" + LS +
+//              "         org.apache.maven.plugin.dependency.collector.its:a:jar:1.0:runtime" + LS +
+
+        assertTrue( strLog.contains( expected ) );
+    }
+
+    /**
+     * collect dependencies, and not inform the transitive optional dependencies. 
+     * @throws Exception if anything goes wrong.
+     */
+    @Test
+    public void noTransitiveOptionalDep()
+        throws Exception
+    {
+        MavenExecutionResult result = mavenExecution.execute( "clean", "validate" );
+
+        result.assertErrorFreeLog();
+
+        // Check that the current plugins has been called at least once.
+        result.assertLogText( "[INFO] --- maven-dependency-collector-plugin:1.0.0:dependency-collector (id-dependency-collector) @ maven-dependency-collector-plugin-it ---" );
+
+        File logFile = new File(basedir, "log.txt");
+        String strLog = FileUtils.fileRead( logFile );
+        
+        String expected = 
+            "PROJECT-DEPENDENCY-COLLECTOR:maven-dependency-collector-plugin-it:jar:1.0.0-A:" + LS +
+            "   org.apache.maven.plugin.dependency.collector.its:d:jar:1.0:compile" + LS + 
+            LS;
+
+        assertTrue( strLog.contains( expected ) );
+    }
+    
+    /**
+     * collect dependencies, and inform when a dependency version is selected from a range. 
+     * @throws Exception if anything goes wrong.
+     */
+    @Test
+    public void versionConstraintDep()
+        throws Exception
+    {
+        MavenExecutionResult result = mavenExecution.execute( "clean", "validate" );
+
+        result.assertErrorFreeLog();
+
         // Check that the current plugins has been called at least once.
         result.assertLogText( "[INFO] --- maven-dependency-collector-plugin:1.0.0:dependency-collector (id-dependency-collector) @ maven-dependency-collector-plugin-it ---" );
 
-        System.out.println( "mavenVersion='" + mavenRuntime.getMavenVersion() + "'" );
+        File logFile = new File(basedir, "log.txt");
+        String strLog = FileUtils.fileRead( logFile );
+        
+        String expected = 
+            "PROJECT-DEPENDENCY-COLLECTOR:maven-dependency-collector-plugin-it:jar:1.0.0-A:" + LS +
+            "   org.apache.maven.plugin.dependency.collector.its:t:jar:1.1:compile (version selected from constraint [1.1,))" + LS +
+            "      org.apache.maven.plugin.dependency.collector.its:u:jar:1.0:compile" + LS +            
+            LS;
+
+        assertTrue( strLog.contains( expected ) );
     }
 
+    /**
+     * collect dependencies, and not inform when a dependency is excluded.
+     * @throws Exception if anything goes wrong.
+     */
+    @Test
+    public void noExcludedDep()
+        throws Exception
+    {
+        MavenExecutionResult result = mavenExecution.execute( "clean", "validate" );
+        
+        result.assertErrorFreeLog();
+
+        // Check that the current plugins has been called at least once.
+        result.assertLogText( "[INFO] --- maven-dependency-collector-plugin:1.0.0:dependency-collector (id-dependency-collector) @ maven-dependency-collector-plugin-it ---" );
+
+        File logFile = new File(basedir, "log.txt");
+        String strLog = FileUtils.fileRead( logFile );
+
+        String expected = 
+            "PROJECT-DEPENDENCY-COLLECTOR:maven-dependency-collector-plugin-it:jar:1.0.0-A:" + LS +
+             "   org.apache.maven.plugin.dependency.collector.its:c:jar:1.0:compile" + LS + 
+             "      org.apache.maven.plugin.dependency.collector.its:b:jar:1.0:compile" + LS + 
+             "   org.apache.maven.plugin.dependency.collector.its:b:jar:1.0:compile" + LS + 
+           LS;
+
+        assertTrue( strLog.contains( expected ) );
+    }
 }
\ No newline at end of file
diff --git a/src/it/maven-dependency-collector-plugin/src/test/projects/managedDepsAndScope/pom.xml b/src/it/maven-dependency-collector-plugin/src/test/projects/managedDepsAndScope/pom.xml
new file mode 100644
index 0000000..06e17b6
--- /dev/null
+++ b/src/it/maven-dependency-collector-plugin/src/test/projects/managedDepsAndScope/pom.xml
@@ -0,0 +1,68 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<!--
+  Licensed to the Apache Software Foundation (ASF) under one
+  or more contributor license agreements. See the NOTICE file
+  distributed with this work for additional information
+  regarding copyright ownership. The ASF licenses this file
+  to you under the Apache License, Version 2.0 (the
+  "License"); you may not use this file except in compliance
+  with the License. You may obtain a copy of the License at
+
+  http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing,
+  software distributed under the License is distributed on an
+  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+  KIND, either express or implied. See the License for the
+  specific language governing permissions and limitations
+  under the License.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+  <modelVersion>4.0.0</modelVersion>
+
+  <groupId>PROJECT-DEPENDENCY-COLLECTOR</groupId>
+  <artifactId>maven-dependency-collector-plugin-it</artifactId>
+  <version>1.0.0-A</version>
+  
+  <dependencyManagement>
+    <dependencies>
+      <dependency>
+        <groupId>org.apache.maven.plugin.dependency.collector.its</groupId>
+        <artifactId>u</artifactId>
+        <version>1.1</version>
+        <scope>test</scope>
+      </dependency>
+    </dependencies>
+  </dependencyManagement>
+  
+  <dependencies>
+    <dependency>
+      <groupId>org.apache.maven.plugin.dependency.collector.its</groupId>
+      <artifactId>t</artifactId>
+      <version>1.1</version>
+    </dependency>
+  </dependencies>
+  
+  <build>
+    <plugins>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-dependency-collector-plugin</artifactId>
+        <version>${it-plugin.version}</version>
+        <configuration>
+          <localRepositoryPath>${localRepositoryPath}</localRepositoryPath>
+          <mvnVersion>${mvnVersion}</mvnVersion>
+        </configuration>
+        <executions>
+          <execution>
+            <id>id-dependency-collector</id>
+            <goals>
+              <goal>dependency-collector</goal>
+            </goals>
+          </execution>
+        </executions>
+      </plugin>
+    </plugins>
+  </build>
+</project>
diff --git a/src/it/maven-dependency-collector-plugin/src/test/projects/mockDependencies/a10/pom.xml b/src/it/maven-dependency-collector-plugin/src/test/projects/mockDependencies/a10/pom.xml
new file mode 100644
index 0000000..d0d62cf
--- /dev/null
+++ b/src/it/maven-dependency-collector-plugin/src/test/projects/mockDependencies/a10/pom.xml
@@ -0,0 +1,34 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<!--
+  Licensed to the Apache Software Foundation (ASF) under one
+  or more contributor license agreements. See the NOTICE file
+  distributed with this work for additional information
+  regarding copyright ownership. The ASF licenses this file
+  to you under the Apache License, Version 2.0 (the
+  "License"); you may not use this file except in compliance
+  with the License. You may obtain a copy of the License at
+
+  http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing,
+  software distributed under the License is distributed on an
+  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+  KIND, either express or implied. See the License for the
+  specific language governing permissions and limitations
+  under the License.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+  <modelVersion>4.0.0</modelVersion>
+  <groupId>org.apache.maven.plugin.dependency.collector.its</groupId>
+  <artifactId>a</artifactId>
+  <version>1.0</version>
+
+  <dependencies>
+    <dependency>
+      <groupId>org.apache.maven.plugin.dependency.collector.its</groupId>
+      <artifactId>t</artifactId>
+      <version>1.0</version>
+      <scope>test</scope>    
+    </dependency>
+  </dependencies>
+</project>
\ No newline at end of file
diff --git a/src/it/maven-dependency-collector-plugin/src/test/projects/mockDependencies/b10/pom.xml b/src/it/maven-dependency-collector-plugin/src/test/projects/mockDependencies/b10/pom.xml
new file mode 100644
index 0000000..5c026c5
--- /dev/null
+++ b/src/it/maven-dependency-collector-plugin/src/test/projects/mockDependencies/b10/pom.xml
@@ -0,0 +1,33 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<!--
+  Licensed to the Apache Software Foundation (ASF) under one
+  or more contributor license agreements. See the NOTICE file
+  distributed with this work for additional information
+  regarding copyright ownership. The ASF licenses this file
+  to you under the Apache License, Version 2.0 (the
+  "License"); you may not use this file except in compliance
+  with the License. You may obtain a copy of the License at
+
+  http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing,
+  software distributed under the License is distributed on an
+  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+  KIND, either express or implied. See the License for the
+  specific language governing permissions and limitations
+  under the License.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+  <modelVersion>4.0.0</modelVersion>
+  <groupId>org.apache.maven.plugin.dependency.collector.its</groupId>
+  <artifactId>b</artifactId>
+  <version>1.0</version>
+
+  <dependencies>
+    <dependency>
+      <groupId>org.apache.maven.plugin.dependency.collector.its</groupId>
+      <artifactId>a</artifactId>
+      <version>1.0</version>
+    </dependency>
+  </dependencies>
+</project>
\ No newline at end of file
diff --git a/src/it/maven-dependency-collector-plugin/src/test/projects/mockDependencies/c10/pom.xml b/src/it/maven-dependency-collector-plugin/src/test/projects/mockDependencies/c10/pom.xml
new file mode 100644
index 0000000..9049b83
--- /dev/null
+++ b/src/it/maven-dependency-collector-plugin/src/test/projects/mockDependencies/c10/pom.xml
@@ -0,0 +1,33 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<!--
+  Licensed to the Apache Software Foundation (ASF) under one
+  or more contributor license agreements. See the NOTICE file
+  distributed with this work for additional information
+  regarding copyright ownership. The ASF licenses this file
+  to you under the Apache License, Version 2.0 (the
+  "License"); you may not use this file except in compliance
+  with the License. You may obtain a copy of the License at
+
+  http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing,
+  software distributed under the License is distributed on an
+  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+  KIND, either express or implied. See the License for the
+  specific language governing permissions and limitations
+  under the License.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+  <modelVersion>4.0.0</modelVersion>
+  <groupId>org.apache.maven.plugin.dependency.collector.its</groupId>
+  <artifactId>c</artifactId>
+  <version>1.0</version>
+
+  <dependencies>
+    <dependency>
+      <groupId>org.apache.maven.plugin.dependency.collector.its</groupId>
+      <artifactId>b</artifactId>
+      <version>1.0</version>
+    </dependency>
+  </dependencies>
+</project>
\ No newline at end of file
diff --git a/src/it/maven-dependency-collector-plugin/src/test/projects/mockDependencies/d10/pom.xml b/src/it/maven-dependency-collector-plugin/src/test/projects/mockDependencies/d10/pom.xml
new file mode 100644
index 0000000..0b20d79
--- /dev/null
+++ b/src/it/maven-dependency-collector-plugin/src/test/projects/mockDependencies/d10/pom.xml
@@ -0,0 +1,34 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<!--
+  Licensed to the Apache Software Foundation (ASF) under one
+  or more contributor license agreements. See the NOTICE file
+  distributed with this work for additional information
+  regarding copyright ownership. The ASF licenses this file
+  to you under the Apache License, Version 2.0 (the
+  "License"); you may not use this file except in compliance
+  with the License. You may obtain a copy of the License at
+
+  http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing,
+  software distributed under the License is distributed on an
+  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+  KIND, either express or implied. See the License for the
+  specific language governing permissions and limitations
+  under the License.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+  <modelVersion>4.0.0</modelVersion>
+  <groupId>org.apache.maven.plugin.dependency.collector.its</groupId>
+  <artifactId>d</artifactId>
+  <version>1.0</version>
+
+  <dependencies>
+    <dependency>
+      <groupId>org.apache.maven.plugin.dependency.collector.its</groupId>
+      <artifactId>c</artifactId>
+      <version>1.0</version>
+      <optional>true</optional>
+    </dependency>
+  </dependencies>
+</project>
\ No newline at end of file
diff --git a/src/it/maven-dependency-collector-plugin/src/test/projects/mockDependencies/pom.xml b/src/it/maven-dependency-collector-plugin/src/test/projects/mockDependencies/pom.xml
new file mode 100644
index 0000000..f9f6abb
--- /dev/null
+++ b/src/it/maven-dependency-collector-plugin/src/test/projects/mockDependencies/pom.xml
@@ -0,0 +1,37 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<!--
+  Licensed to the Apache Software Foundation (ASF) under one
+  or more contributor license agreements. See the NOTICE file
+  distributed with this work for additional information
+  regarding copyright ownership. The ASF licenses this file
+  to you under the Apache License, Version 2.0 (the
+  "License"); you may not use this file except in compliance
+  with the License. You may obtain a copy of the License at
+
+  http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing,
+  software distributed under the License is distributed on an
+  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+  KIND, either express or implied. See the License for the
+  specific language governing permissions and limitations
+  under the License.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+  <modelVersion>4.0.0</modelVersion>
+  <groupId>org.apache.maven.plugin.dependency.collector.its</groupId>
+  <artifactId>all-dependencies-project</artifactId>
+  <version>1.0</version>
+  <packaging>pom</packaging>
+  
+  <modules>
+    <module>u10</module>
+    <module>u11</module>
+    <module>t10</module>
+    <module>t11</module>
+    <module>a10</module>
+    <module>b10</module>
+    <module>c10</module>
+    <module>d10</module>
+  </modules>
+</project>
\ No newline at end of file
diff --git a/src/it/maven-dependency-collector-plugin/src/test/projects/mockDependencies/t10/pom.xml b/src/it/maven-dependency-collector-plugin/src/test/projects/mockDependencies/t10/pom.xml
new file mode 100644
index 0000000..46221db
--- /dev/null
+++ b/src/it/maven-dependency-collector-plugin/src/test/projects/mockDependencies/t10/pom.xml
@@ -0,0 +1,25 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<!--
+  Licensed to the Apache Software Foundation (ASF) under one
+  or more contributor license agreements. See the NOTICE file
+  distributed with this work for additional information
+  regarding copyright ownership. The ASF licenses this file
+  to you under the Apache License, Version 2.0 (the
+  "License"); you may not use this file except in compliance
+  with the License. You may obtain a copy of the License at
+
+  http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing,
+  software distributed under the License is distributed on an
+  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+  KIND, either express or implied. See the License for the
+  specific language governing permissions and limitations
+  under the License.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+  <modelVersion>4.0.0</modelVersion>
+  <groupId>org.apache.maven.plugin.dependency.collector.its</groupId>
+  <artifactId>t</artifactId>
+  <version>1.0</version>
+</project>
\ No newline at end of file
diff --git a/src/it/maven-dependency-collector-plugin/src/test/projects/mockDependencies/t11/pom.xml b/src/it/maven-dependency-collector-plugin/src/test/projects/mockDependencies/t11/pom.xml
new file mode 100644
index 0000000..c7d8e8d
--- /dev/null
+++ b/src/it/maven-dependency-collector-plugin/src/test/projects/mockDependencies/t11/pom.xml
@@ -0,0 +1,33 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<!--
+  Licensed to the Apache Software Foundation (ASF) under one
+  or more contributor license agreements. See the NOTICE file
+  distributed with this work for additional information
+  regarding copyright ownership. The ASF licenses this file
+  to you under the Apache License, Version 2.0 (the
+  "License"); you may not use this file except in compliance
+  with the License. You may obtain a copy of the License at
+
+  http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing,
+  software distributed under the License is distributed on an
+  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+  KIND, either express or implied. See the License for the
+  specific language governing permissions and limitations
+  under the License.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+  <modelVersion>4.0.0</modelVersion>
+  <groupId>org.apache.maven.plugin.dependency.collector.its</groupId>
+  <artifactId>t</artifactId>
+  <version>1.1</version>
+  
+  <dependencies>
+    <dependency>
+      <groupId>org.apache.maven.plugin.dependency.collector.its</groupId>
+      <artifactId>u</artifactId>
+      <version>1.0</version>    
+    </dependency>
+  </dependencies>
+</project>
\ No newline at end of file
diff --git a/src/it/maven-dependency-collector-plugin/src/test/projects/mockDependencies/u10/pom.xml b/src/it/maven-dependency-collector-plugin/src/test/projects/mockDependencies/u10/pom.xml
new file mode 100644
index 0000000..d43b1da
--- /dev/null
+++ b/src/it/maven-dependency-collector-plugin/src/test/projects/mockDependencies/u10/pom.xml
@@ -0,0 +1,25 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<!--
+  Licensed to the Apache Software Foundation (ASF) under one
+  or more contributor license agreements. See the NOTICE file
+  distributed with this work for additional information
+  regarding copyright ownership. The ASF licenses this file
+  to you under the Apache License, Version 2.0 (the
+  "License"); you may not use this file except in compliance
+  with the License. You may obtain a copy of the License at
+
+  http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing,
+  software distributed under the License is distributed on an
+  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+  KIND, either express or implied. See the License for the
+  specific language governing permissions and limitations
+  under the License.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+  <modelVersion>4.0.0</modelVersion>
+  <groupId>org.apache.maven.plugin.dependency.collector.its</groupId>
+  <artifactId>u</artifactId>
+  <version>1.0</version>
+</project>
\ No newline at end of file
diff --git a/src/it/maven-dependency-collector-plugin/src/test/projects/mockDependencies/u11/pom.xml b/src/it/maven-dependency-collector-plugin/src/test/projects/mockDependencies/u11/pom.xml
new file mode 100644
index 0000000..8e08eee
--- /dev/null
+++ b/src/it/maven-dependency-collector-plugin/src/test/projects/mockDependencies/u11/pom.xml
@@ -0,0 +1,25 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<!--
+  Licensed to the Apache Software Foundation (ASF) under one
+  or more contributor license agreements. See the NOTICE file
+  distributed with this work for additional information
+  regarding copyright ownership. The ASF licenses this file
+  to you under the Apache License, Version 2.0 (the
+  "License"); you may not use this file except in compliance
+  with the License. You may obtain a copy of the License at
+
+  http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing,
+  software distributed under the License is distributed on an
+  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+  KIND, either express or implied. See the License for the
+  specific language governing permissions and limitations
+  under the License.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+  <modelVersion>4.0.0</modelVersion>
+  <groupId>org.apache.maven.plugin.dependency.collector.its</groupId>
+  <artifactId>u</artifactId>
+  <version>1.1</version>
+</project>
\ No newline at end of file
diff --git a/src/it/maven-dependency-collector-plugin/src/test/projects/noExcludedDep/pom.xml b/src/it/maven-dependency-collector-plugin/src/test/projects/noExcludedDep/pom.xml
new file mode 100644
index 0000000..9d905d9
--- /dev/null
+++ b/src/it/maven-dependency-collector-plugin/src/test/projects/noExcludedDep/pom.xml
@@ -0,0 +1,68 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<!--
+  Licensed to the Apache Software Foundation (ASF) under one
+  or more contributor license agreements. See the NOTICE file
+  distributed with this work for additional information
+  regarding copyright ownership. The ASF licenses this file
+  to you under the Apache License, Version 2.0 (the
+  "License"); you may not use this file except in compliance
+  with the License. You may obtain a copy of the License at
+
+  http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing,
+  software distributed under the License is distributed on an
+  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+  KIND, either express or implied. See the License for the
+  specific language governing permissions and limitations
+  under the License.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+  <modelVersion>4.0.0</modelVersion>
+
+  <groupId>PROJECT-DEPENDENCY-COLLECTOR</groupId>
+  <artifactId>maven-dependency-collector-plugin-it</artifactId>
+  <version>1.0.0-A</version>
+
+  <dependencies>
+    <dependency>
+      <groupId>org.apache.maven.plugin.dependency.collector.its</groupId>
+      <artifactId>c</artifactId>
+      <version>1.0</version>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.maven.plugin.dependency.collector.its</groupId>
+      <artifactId>b</artifactId>
+      <version>1.0</version>
+      <exclusions>
+        <exclusion>
+          <groupId>org.apache.maven.plugin.dependency.collector.its</groupId>
+          <artifactId>a</artifactId>
+        </exclusion>
+      </exclusions>
+    </dependency>
+  </dependencies>
+  
+  <build>
+    <plugins>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-dependency-collector-plugin</artifactId>
+        <version>${it-plugin.version}</version>
+        <configuration>
+          <localRepositoryPath>${localRepositoryPath}</localRepositoryPath>
+          <mvnVersion>${mvnVersion}</mvnVersion>
+        </configuration>
+        <executions>
+          <execution>
+            <id>id-dependency-collector</id>
+            <goals>
+              <goal>dependency-collector</goal>
+            </goals>
+          </execution>
+        </executions>
+      </plugin>
+    </plugins>
+  </build>
+</project>
diff --git a/src/it/maven-dependency-collector-plugin/src/test/projects/noRepeatedDeps/pom.xml b/src/it/maven-dependency-collector-plugin/src/test/projects/noRepeatedDeps/pom.xml
new file mode 100644
index 0000000..33959c1
--- /dev/null
+++ b/src/it/maven-dependency-collector-plugin/src/test/projects/noRepeatedDeps/pom.xml
@@ -0,0 +1,62 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<!--
+  Licensed to the Apache Software Foundation (ASF) under one
+  or more contributor license agreements. See the NOTICE file
+  distributed with this work for additional information
+  regarding copyright ownership. The ASF licenses this file
+  to you under the Apache License, Version 2.0 (the
+  "License"); you may not use this file except in compliance
+  with the License. You may obtain a copy of the License at
+
+  http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing,
+  software distributed under the License is distributed on an
+  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+  KIND, either express or implied. See the License for the
+  specific language governing permissions and limitations
+  under the License.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+  <modelVersion>4.0.0</modelVersion>
+
+  <groupId>PROJECT-DEPENDENCY-COLLECTOR</groupId>
+  <artifactId>maven-dependency-collector-plugin-it</artifactId>
+  <version>1.0.0-A</version>
+
+  <dependencies>
+    <dependency>
+      <groupId>org.apache.maven.plugin.dependency.collector.its</groupId>
+      <artifactId>c</artifactId>
+      <version>1.0</version>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.maven.plugin.dependency.collector.its</groupId>
+      <artifactId>b</artifactId>
+      <version>1.0</version>
+    </dependency>
+</dependencies>
+  
+  <build>
+    <plugins>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-dependency-collector-plugin</artifactId>
+        <version>${it-plugin.version}</version>
+        <configuration>
+          <localRepositoryPath>${localRepositoryPath}</localRepositoryPath>
+          <mvnVersion>${mvnVersion}</mvnVersion>
+        </configuration>
+        <executions>
+          <execution>
+            <id>id-dependency-collector</id>
+            <goals>
+              <goal>dependency-collector</goal>
+            </goals>
+          </execution>
+        </executions>
+      </plugin>
+    </plugins>
+  </build>
+</project>
diff --git a/src/it/maven-dependency-collector-plugin/src/test/projects/noTransitiveOptionalDep/pom.xml b/src/it/maven-dependency-collector-plugin/src/test/projects/noTransitiveOptionalDep/pom.xml
new file mode 100644
index 0000000..003b6a3
--- /dev/null
+++ b/src/it/maven-dependency-collector-plugin/src/test/projects/noTransitiveOptionalDep/pom.xml
@@ -0,0 +1,57 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<!--
+  Licensed to the Apache Software Foundation (ASF) under one
+  or more contributor license agreements. See the NOTICE file
+  distributed with this work for additional information
+  regarding copyright ownership. The ASF licenses this file
+  to you under the Apache License, Version 2.0 (the
+  "License"); you may not use this file except in compliance
+  with the License. You may obtain a copy of the License at
+
+  http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing,
+  software distributed under the License is distributed on an
+  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+  KIND, either express or implied. See the License for the
+  specific language governing permissions and limitations
+  under the License.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+  <modelVersion>4.0.0</modelVersion>
+
+  <groupId>PROJECT-DEPENDENCY-COLLECTOR</groupId>
+  <artifactId>maven-dependency-collector-plugin-it</artifactId>
+  <version>1.0.0-A</version>
+
+  <dependencies>
+    <dependency>
+      <groupId>org.apache.maven.plugin.dependency.collector.its</groupId>
+      <artifactId>d</artifactId>
+      <version>1.0</version>
+    </dependency>
+  </dependencies>
+  
+  <build>
+    <plugins>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-dependency-collector-plugin</artifactId>
+        <version>${it-plugin.version}</version>
+        <configuration>
+          <localRepositoryPath>${localRepositoryPath}</localRepositoryPath>
+          <mvnVersion>${mvnVersion}</mvnVersion>
+        </configuration>
+        <executions>
+          <execution>
+            <id>id-dependency-collector</id>
+            <goals>
+              <goal>dependency-collector</goal>
+            </goals>
+          </execution>
+        </executions>
+      </plugin>
+    </plugins>
+  </build>
+</project>
diff --git a/src/it/maven-dependency-collector-plugin/src/test/projects/noTransitiveTestDep/pom.xml b/src/it/maven-dependency-collector-plugin/src/test/projects/noTransitiveTestDep/pom.xml
new file mode 100644
index 0000000..47ae154
--- /dev/null
+++ b/src/it/maven-dependency-collector-plugin/src/test/projects/noTransitiveTestDep/pom.xml
@@ -0,0 +1,63 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<!--
+  Licensed to the Apache Software Foundation (ASF) under one
+  or more contributor license agreements. See the NOTICE file
+  distributed with this work for additional information
+  regarding copyright ownership. The ASF licenses this file
+  to you under the Apache License, Version 2.0 (the
+  "License"); you may not use this file except in compliance
+  with the License. You may obtain a copy of the License at
+
+  http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing,
+  software distributed under the License is distributed on an
+  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+  KIND, either express or implied. See the License for the
+  specific language governing permissions and limitations
+  under the License.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+  <modelVersion>4.0.0</modelVersion>
+
+  <groupId>PROJECT-DEPENDENCY-COLLECTOR</groupId>
+  <artifactId>maven-dependency-collector-plugin-it</artifactId>
+  <version>1.0.0-A</version>
+
+  <dependencies>
+    <dependency>
+      <groupId>org.apache.maven.plugin.dependency.collector.its</groupId>
+      <artifactId>a</artifactId>
+      <version>1.0</version>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.maven.plugin.dependency.collector.its</groupId>
+      <artifactId>u</artifactId>
+      <version>1.0</version>
+      <scope>test</scope>
+    </dependency>
+  </dependencies>
+  
+  <build>
+    <plugins>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-dependency-collector-plugin</artifactId>
+        <version>${it-plugin.version}</version>
+        <configuration>
+          <localRepositoryPath>${localRepositoryPath}</localRepositoryPath>
+          <mvnVersion>${mvnVersion}</mvnVersion>
+        </configuration>
+        <executions>
+          <execution>
+            <id>id-dependency-collector</id>
+            <goals>
+              <goal>dependency-collector</goal>
+            </goals>
+          </execution>
+        </executions>
+      </plugin>
+    </plugins>
+  </build>
+</project>
diff --git a/src/it/maven-dependency-collector-plugin/src/test/projects/optionalDep/pom.xml b/src/it/maven-dependency-collector-plugin/src/test/projects/optionalDep/pom.xml
new file mode 100644
index 0000000..12c80e7
--- /dev/null
+++ b/src/it/maven-dependency-collector-plugin/src/test/projects/optionalDep/pom.xml
@@ -0,0 +1,59 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<!--
+  Licensed to the Apache Software Foundation (ASF) under one
+  or more contributor license agreements. See the NOTICE file
+  distributed with this work for additional information
+  regarding copyright ownership. The ASF licenses this file
+  to you under the Apache License, Version 2.0 (the
+  "License"); you may not use this file except in compliance
+  with the License. You may obtain a copy of the License at
+
+  http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing,
+  software distributed under the License is distributed on an
+  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+  KIND, either express or implied. See the License for the
+  specific language governing permissions and limitations
+  under the License.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+  <modelVersion>4.0.0</modelVersion>
+
+  <groupId>PROJECT-DEPENDENCY-COLLECTOR</groupId>
+  <artifactId>maven-dependency-collector-plugin-it</artifactId>
+  <version>1.0.0-A</version>
+
+  <dependencies>
+    <dependency>
+      <groupId>org.apache.maven.plugin.dependency.collector.its</groupId>
+      <artifactId>c</artifactId>
+      <version>1.0</version>
+      <scope>runtime</scope>
+      <optional>true</optional>
+    </dependency>
+  </dependencies>
+  
+  <build>
+    <plugins>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-dependency-collector-plugin</artifactId>
+        <version>${it-plugin.version}</version>
+        <configuration>
+          <localRepositoryPath>${localRepositoryPath}</localRepositoryPath>
+          <mvnVersion>${mvnVersion}</mvnVersion>
+        </configuration>
+        <executions>
+          <execution>
+            <id>id-dependency-collector</id>
+            <goals>
+              <goal>dependency-collector</goal>
+            </goals>
+          </execution>
+        </executions>
+      </plugin>
+    </plugins>
+  </build>
+</project>
diff --git a/src/it/maven-dependency-collector-plugin/src/test/projects/transitiveTestDeps/pom.xml b/src/it/maven-dependency-collector-plugin/src/test/projects/transitiveTestDeps/pom.xml
new file mode 100644
index 0000000..38e7e4f
--- /dev/null
+++ b/src/it/maven-dependency-collector-plugin/src/test/projects/transitiveTestDeps/pom.xml
@@ -0,0 +1,58 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<!--
+  Licensed to the Apache Software Foundation (ASF) under one
+  or more contributor license agreements. See the NOTICE file
+  distributed with this work for additional information
+  regarding copyright ownership. The ASF licenses this file
+  to you under the Apache License, Version 2.0 (the
+  "License"); you may not use this file except in compliance
+  with the License. You may obtain a copy of the License at
+
+  http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing,
+  software distributed under the License is distributed on an
+  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+  KIND, either express or implied. See the License for the
+  specific language governing permissions and limitations
+  under the License.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+  <modelVersion>4.0.0</modelVersion>
+
+  <groupId>PROJECT-DEPENDENCY-COLLECTOR</groupId>
+  <artifactId>maven-dependency-collector-plugin-it</artifactId>
+  <version>1.0.0-A</version>
+
+  <dependencies>
+    <dependency>
+      <groupId>org.apache.maven.plugin.dependency.collector.its</groupId>
+      <artifactId>t</artifactId>
+      <version>1.1</version>
+      <scope>test</scope>
+    </dependency>
+</dependencies>
+  
+  <build>
+    <plugins>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-dependency-collector-plugin</artifactId>
+        <version>${it-plugin.version}</version>
+        <configuration>
+          <localRepositoryPath>${localRepositoryPath}</localRepositoryPath>
+          <mvnVersion>${mvnVersion}</mvnVersion>
+        </configuration>
+        <executions>
+          <execution>
+            <id>id-dependency-collector</id>
+            <goals>
+              <goal>dependency-collector</goal>
+            </goals>
+          </execution>
+        </executions>
+      </plugin>
+    </plugins>
+  </build>
+</project>
diff --git a/src/it/maven-dependency-collector-plugin/src/test/projects/versionConstraintDep/pom.xml b/src/it/maven-dependency-collector-plugin/src/test/projects/versionConstraintDep/pom.xml
new file mode 100644
index 0000000..947f236
--- /dev/null
+++ b/src/it/maven-dependency-collector-plugin/src/test/projects/versionConstraintDep/pom.xml
@@ -0,0 +1,57 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<!--
+  Licensed to the Apache Software Foundation (ASF) under one
+  or more contributor license agreements. See the NOTICE file
+  distributed with this work for additional information
+  regarding copyright ownership. The ASF licenses this file
+  to you under the Apache License, Version 2.0 (the
+  "License"); you may not use this file except in compliance
+  with the License. You may obtain a copy of the License at
+
+  http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing,
+  software distributed under the License is distributed on an
+  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+  KIND, either express or implied. See the License for the
+  specific language governing permissions and limitations
+  under the License.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+  <modelVersion>4.0.0</modelVersion>
+
+  <groupId>PROJECT-DEPENDENCY-COLLECTOR</groupId>
+  <artifactId>maven-dependency-collector-plugin-it</artifactId>
+  <version>1.0.0-A</version>
+  
+  <dependencies>
+    <dependency>
+      <groupId>org.apache.maven.plugin.dependency.collector.its</groupId>
+      <artifactId>t</artifactId>
+      <version>[1.1,)</version>
+    </dependency>
+</dependencies>
+  
+  <build>
+    <plugins>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-dependency-collector-plugin</artifactId>
+        <version>${it-plugin.version}</version>
+        <configuration>
+          <localRepositoryPath>${localRepositoryPath}</localRepositoryPath>
+          <mvnVersion>${mvnVersion}</mvnVersion>
+        </configuration>
+        <executions>
+          <execution>
+            <id>id-dependency-collector</id>
+            <goals>
+              <goal>dependency-collector</goal>
+            </goals>
+          </execution>
+        </executions>
+      </plugin>
+    </plugins>
+  </build>
+</project>
diff --git a/src/main/java/org/apache/maven/shared/transfer/dependencies/collect/CollectorResult.java b/src/main/java/org/apache/maven/shared/transfer/dependencies/collect/CollectorResult.java
index d5a13b5..e68e946 100644
--- a/src/main/java/org/apache/maven/shared/transfer/dependencies/collect/CollectorResult.java
+++ b/src/main/java/org/apache/maven/shared/transfer/dependencies/collect/CollectorResult.java
@@ -22,6 +22,7 @@ package org.apache.maven.shared.transfer.dependencies.collect;
 import java.util.List;
 
 import org.apache.maven.artifact.repository.ArtifactRepository;
+import org.apache.maven.shared.dependency.graph.DependencyNode;
 
 /**
  * 
@@ -34,4 +35,9 @@ public interface CollectorResult
      * @return List of {@link ArtifactRepository}
      */
     List<ArtifactRepository> getRemoteRepositories();
+
+    /***
+     * @return the root of the dependency graph
+     */
+    DependencyNode getDependencyGraphRoot();
 }
diff --git a/src/main/java/org/apache/maven/shared/transfer/dependencies/collect/DependencyCollector.java b/src/main/java/org/apache/maven/shared/transfer/dependencies/collect/DependencyCollector.java
index 2134776..325855a 100644
--- a/src/main/java/org/apache/maven/shared/transfer/dependencies/collect/DependencyCollector.java
+++ b/src/main/java/org/apache/maven/shared/transfer/dependencies/collect/DependencyCollector.java
@@ -70,4 +70,38 @@ public interface DependencyCollector
     CollectorResult collectDependencies( ProjectBuildingRequest buildingRequest, Model root )
                     throws DependencyCollectorException;
 
+    /**
+     * @param buildingRequest {@link ProjectBuildingRequest}.
+     * @param root {@link Dependency}
+     * @return {@link CollectorResult}
+     * @throws DependencyCollectorException in case of an error which can be a component lookup error or an error while
+     *             trying to collect the dependencies.
+     * @throws IllegalArgumentException in case of parameter <code>buildingRequest</code> is <code>null</code>
+     */
+    CollectorResult collectDependenciesGraph( ProjectBuildingRequest buildingRequest, Dependency root )
+        throws DependencyCollectorException;
+
+    /**
+     * @param buildingRequest {@link ProjectBuildingRequest}.
+     * @param root {@link DependableCoordinate}
+     * @return {@link CollectorResult}
+     * @throws DependencyCollectorException in case of an error which can be a component lookup error or an error while
+     *             trying to collect the dependencies.
+     * @throws IllegalArgumentException in case of parameter <code>buildingRequest</code> is <code>null</code>
+     */
+    CollectorResult collectDependenciesGraph( ProjectBuildingRequest buildingRequest, DependableCoordinate root )
+        throws DependencyCollectorException;
+
+    /**
+     * @param buildingRequest {@link ProjectBuildingRequest}.
+     * @param root {@link Model}
+     * @return {@link CollectorResult}
+     * @throws DependencyCollectorException in case of an error which can be a component lookup error or an error while
+     *             trying to collect the dependencies.
+     * @throws IllegalArgumentException in case of parameter <code>buildingRequest</code> is <code>null</code>
+     */
+    CollectorResult collectDependenciesGraph( ProjectBuildingRequest buildingRequest, Model root )
+        throws DependencyCollectorException;
+
+    
 }
diff --git a/src/main/java/org/apache/maven/shared/transfer/dependencies/collect/internal/DefaultDependencyCollector.java b/src/main/java/org/apache/maven/shared/transfer/dependencies/collect/internal/DefaultDependencyCollector.java
index 2f5a22a..d07c738 100644
--- a/src/main/java/org/apache/maven/shared/transfer/dependencies/collect/internal/DefaultDependencyCollector.java
+++ b/src/main/java/org/apache/maven/shared/transfer/dependencies/collect/internal/DefaultDependencyCollector.java
@@ -74,6 +74,30 @@ class DefaultDependencyCollector implements DependencyCollector
         return getMavenDependencyCollector( buildingRequest ).collectDependencies( root );
     }
 
+    @Override
+    public CollectorResult collectDependenciesGraph( ProjectBuildingRequest buildingRequest, Model root )
+            throws DependencyCollectorException
+    {
+        validateBuildingRequest( buildingRequest );
+        return getMavenDependencyCollector( buildingRequest ).collectDependenciesGraph( root );
+    }
+
+    @Override
+    public CollectorResult collectDependenciesGraph( ProjectBuildingRequest buildingRequest, DependableCoordinate root )
+            throws DependencyCollectorException
+    {
+        validateBuildingRequest( buildingRequest );
+        return getMavenDependencyCollector( buildingRequest ).collectDependenciesGraph( root );
+    }
+
+    @Override
+    public CollectorResult collectDependenciesGraph( ProjectBuildingRequest buildingRequest, Dependency root )
+            throws DependencyCollectorException
+    {
+        validateBuildingRequest( buildingRequest );
+        return getMavenDependencyCollector( buildingRequest ).collectDependenciesGraph( root );
+    }
+
     private void validateParameters( ProjectBuildingRequest buildingRequest, DependableCoordinate root )
     {
         validateBuildingRequest( buildingRequest );
diff --git a/src/main/java/org/apache/maven/shared/transfer/dependencies/collect/internal/Maven31CollectorResult.java b/src/main/java/org/apache/maven/shared/transfer/dependencies/collect/internal/Maven31CollectorResult.java
index dbf8717..9984a8c 100644
--- a/src/main/java/org/apache/maven/shared/transfer/dependencies/collect/internal/Maven31CollectorResult.java
+++ b/src/main/java/org/apache/maven/shared/transfer/dependencies/collect/internal/Maven31CollectorResult.java
@@ -20,16 +20,24 @@ package org.apache.maven.shared.transfer.dependencies.collect.internal;
  */
 
 import java.util.ArrayList;
+import java.util.Collections;
 import java.util.HashSet;
 import java.util.List;
 import java.util.Set;
 
+import org.apache.maven.RepositoryUtils;
 import org.apache.maven.artifact.repository.ArtifactRepository;
+import org.apache.maven.artifact.resolver.filter.ArtifactFilter;
+import org.apache.maven.shared.dependency.graph.internal.DefaultDependencyNode;
 import org.apache.maven.shared.transfer.dependencies.collect.CollectorResult;
+import org.eclipse.aether.artifact.Artifact;
 import org.eclipse.aether.collection.CollectResult;
+import org.eclipse.aether.graph.Dependency;
 import org.eclipse.aether.graph.DependencyNode;
 import org.eclipse.aether.graph.DependencyVisitor;
 import org.eclipse.aether.repository.RemoteRepository;
+import org.eclipse.aether.util.graph.manager.DependencyManagerUtils;
+import org.eclipse.aether.version.VersionConstraint;
 
 /**
  * CollectorResult wrapper around {@link CollectResult}
@@ -82,4 +90,63 @@ class Maven31CollectorResult implements CollectorResult
         return mavenRepositories;
     }
 
+    @Override
+    public org.apache.maven.shared.dependency.graph.DependencyNode getDependencyGraphRoot()
+    {
+        DependencyNode root = collectResult.getRoot();
+        org.apache.maven.artifact.Artifact rootArtifact = getDependencyArtifact( root.getDependency() );
+
+        return buildDependencyNode( null, root, rootArtifact, null );
+    }
+
+    private org.apache.maven.shared.dependency.graph.DependencyNode buildDependencyNode(
+            org.apache.maven.shared.dependency.graph.DependencyNode parent, DependencyNode node,
+            org.apache.maven.artifact.Artifact artifact, ArtifactFilter filter )
+    {
+        String premanagedVersion = DependencyManagerUtils.getPremanagedVersion( node );
+        String premanagedScope = DependencyManagerUtils.getPremanagedScope( node );
+
+        Boolean optional = null;
+        if ( node.getDependency() != null )
+        {
+            optional = node.getDependency().isOptional();
+        }
+
+        DefaultDependencyNode current =
+            new DefaultDependencyNode( parent, artifact, premanagedVersion, premanagedScope,
+                                       getVersionSelectedFromRange( node.getVersionConstraint() ), optional );
+
+        List<org.apache.maven.shared.dependency.graph.DependencyNode> nodes = new ArrayList<>(
+                node.getChildren().size() );
+        for ( DependencyNode child : node.getChildren() )
+        {
+            org.apache.maven.artifact.Artifact childArtifact = getDependencyArtifact( child.getDependency() );
+
+            if ( ( filter == null ) || filter.include( childArtifact ) )
+            {
+                nodes.add( buildDependencyNode( current, child, childArtifact, filter ) );
+            }
+        }
+
+        current.setChildren( Collections.unmodifiableList( nodes ) );
+        return current;
+    }
+
+    private String getVersionSelectedFromRange( VersionConstraint constraint )
+    {
+        if ( ( constraint == null ) || ( constraint.getVersion() != null ) )
+        {
+            return null;
+        }
+        return constraint.getRange().toString();
+    }
+
+    private org.apache.maven.artifact.Artifact getDependencyArtifact( Dependency dep )
+    {
+        Artifact artifact = dep.getArtifact();
+        org.apache.maven.artifact.Artifact mavenArtifact = RepositoryUtils.toArtifact( artifact );
+        mavenArtifact.setScope( dep.getScope() );
+        mavenArtifact.setOptional( dep.isOptional() );
+        return mavenArtifact;
+    }
 }
diff --git a/src/main/java/org/apache/maven/shared/transfer/dependencies/collect/internal/Maven31DependencyCollector.java b/src/main/java/org/apache/maven/shared/transfer/dependencies/collect/internal/Maven31DependencyCollector.java
index 924637a..bd550ed 100644
--- a/src/main/java/org/apache/maven/shared/transfer/dependencies/collect/internal/Maven31DependencyCollector.java
+++ b/src/main/java/org/apache/maven/shared/transfer/dependencies/collect/internal/Maven31DependencyCollector.java
@@ -27,15 +27,29 @@ import org.apache.maven.shared.transfer.dependencies.DependableCoordinate;
 import org.apache.maven.shared.transfer.dependencies.collect.CollectorResult;
 import org.apache.maven.shared.transfer.dependencies.collect.DependencyCollector;
 import org.apache.maven.shared.transfer.dependencies.collect.DependencyCollectorException;
+import org.eclipse.aether.DefaultRepositorySystemSession;
 import org.eclipse.aether.RepositorySystem;
 import org.eclipse.aether.RepositorySystemSession;
 import org.eclipse.aether.artifact.Artifact;
 import org.eclipse.aether.artifact.ArtifactTypeRegistry;
 import org.eclipse.aether.artifact.DefaultArtifact;
 import org.eclipse.aether.collection.CollectRequest;
+import org.eclipse.aether.collection.CollectResult;
 import org.eclipse.aether.collection.DependencyCollectionException;
+import org.eclipse.aether.collection.DependencyGraphTransformer;
+import org.eclipse.aether.collection.DependencySelector;
 import org.eclipse.aether.graph.Dependency;
 import org.eclipse.aether.repository.RemoteRepository;
+import org.eclipse.aether.util.artifact.JavaScopes;
+import org.eclipse.aether.util.graph.manager.DependencyManagerUtils;
+import org.eclipse.aether.util.graph.selector.AndDependencySelector;
+import org.eclipse.aether.util.graph.selector.ExclusionDependencySelector;
+import org.eclipse.aether.util.graph.selector.OptionalDependencySelector;
+import org.eclipse.aether.util.graph.transformer.ConflictResolver;
+import org.eclipse.aether.util.graph.transformer.JavaScopeDeriver;
+import org.eclipse.aether.util.graph.transformer.JavaScopeSelector;
+import org.eclipse.aether.util.graph.transformer.NearestVersionSelector;
+import org.eclipse.aether.util.graph.transformer.SimpleOptionalitySelector;
 
 import java.util.ArrayList;
 import java.util.List;
@@ -133,6 +147,73 @@ class Maven31DependencyCollector implements MavenDependencyCollector
 
         return collectDependencies( request );
     }
+    @Override
+    public CollectorResult collectDependenciesGraph( org.apache.maven.model.Dependency root )
+            throws DependencyCollectorException
+    {
+        CollectRequest request = new CollectRequest();
+        request.setRoot( toDependency( root, RepositoryUtils.newArtifactTypeRegistry( artifactHandlerManager ) ) );
+
+        return collectDependenciesGraph( request );
+    }
+
+    @Override
+    public CollectorResult collectDependenciesGraph( DependableCoordinate root )
+            throws DependencyCollectorException
+    {
+        ArtifactHandler artifactHandler = artifactHandlerManager.getArtifactHandler( root.getType() );
+
+        String extension = artifactHandler != null ? artifactHandler.getExtension() : null;
+
+        Artifact aetherArtifact = new DefaultArtifact( root.getGroupId(), root.getArtifactId(), root.getClassifier(),
+                extension, root.getVersion() );
+
+        CollectRequest request = new CollectRequest();
+        request.setRoot( new Dependency( aetherArtifact, null ) );
+
+        return collectDependenciesGraph( request );
+    }
+
+    @Override
+    public CollectorResult collectDependenciesGraph( Model root )
+            throws DependencyCollectorException
+    {
+        // Are there examples where packaging and type are NOT in sync
+        ArtifactHandler artifactHandler = artifactHandlerManager.getArtifactHandler( root.getPackaging() );
+
+        String extension = artifactHandler != null ? artifactHandler.getExtension() : null;
+
+        Artifact aetherArtifact =
+                new DefaultArtifact( root.getGroupId(), root.getArtifactId(), extension, root.getVersion() );
+
+        CollectRequest request = new CollectRequest();
+        request.setRoot( new Dependency( aetherArtifact, null ) );
+
+        ArtifactTypeRegistry typeRegistry =
+                RepositoryUtils.newArtifactTypeRegistry( artifactHandlerManager );
+
+        List<Dependency> aetherDependencies = new ArrayList<>( root.getDependencies().size() );
+        for ( org.apache.maven.model.Dependency mavenDependency : root.getDependencies() )
+        {
+            aetherDependencies.add( toDependency( mavenDependency, typeRegistry ) );
+        }
+        request.setDependencies( aetherDependencies );
+
+        if ( root.getDependencyManagement() != null )
+        {
+            List<Dependency> aetherManagerDependencies =
+                    new ArrayList<>( root.getDependencyManagement().getDependencies().size() );
+
+            for ( org.apache.maven.model.Dependency mavenDependency : root.getDependencyManagement().getDependencies() )
+            {
+                aetherManagerDependencies.add( toDependency( mavenDependency, typeRegistry ) );
+            }
+
+            request.setManagedDependencies( aetherManagerDependencies );
+        }
+
+        return collectDependenciesGraph( request );
+    }
 
     private CollectorResult collectDependencies( CollectRequest request ) throws DependencyCollectorException
     {
@@ -147,4 +228,38 @@ class Maven31DependencyCollector implements MavenDependencyCollector
             throw new DependencyCollectorException( e.getMessage(), e );
         }
     }
+    private CollectorResult collectDependenciesGraph( CollectRequest request )
+            throws DependencyCollectorException
+    {
+        DefaultRepositorySystemSession session = new DefaultRepositorySystemSession( this.session );
+        try
+        {
+            DependencyGraphTransformer transformer =
+                    new ConflictResolver( new NearestVersionSelector(), new JavaScopeSelector(),
+                            new SimpleOptionalitySelector(), new JavaScopeDeriver() );
+            session.setDependencyGraphTransformer( transformer );
+
+            DependencySelector depFilter =
+                    new AndDependencySelector( new Maven31DirectScopeDependencySelector( JavaScopes.TEST ),
+                            new OptionalDependencySelector(), new ExclusionDependencySelector() );
+            session.setDependencySelector( depFilter );
+
+            session.setConfigProperty( ConflictResolver.CONFIG_PROP_VERBOSE, true );
+            session.setConfigProperty( DependencyManagerUtils.CONFIG_PROP_VERBOSE, true );
+
+            request.setRepositories( aetherRepositories );
+
+            CollectResult collectResult = repositorySystem.collectDependencies( session, request );
+
+            return new Maven31CollectorResult( collectResult );
+        }
+        catch ( DependencyCollectionException e )
+        {
+            throw new DependencyCollectorException( "Could not collect dependencies: " + e.getResult(), e );
+        }
+        finally
+        {
+            session.setReadOnly();
+        }
+    }
 }
diff --git a/src/main/java/org/apache/maven/shared/transfer/dependencies/collect/internal/Maven31DirectScopeDependencySelector.java b/src/main/java/org/apache/maven/shared/transfer/dependencies/collect/internal/Maven31DirectScopeDependencySelector.java
new file mode 100644
index 0000000..780c530
--- /dev/null
+++ b/src/main/java/org/apache/maven/shared/transfer/dependencies/collect/internal/Maven31DirectScopeDependencySelector.java
@@ -0,0 +1,121 @@
+package org.apache.maven.shared.transfer.dependencies.collect.internal;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import java.util.Objects;
+
+import org.eclipse.aether.collection.DependencyCollectionContext;
+import org.eclipse.aether.collection.DependencySelector;
+import org.eclipse.aether.graph.Dependency;
+
+/**
+ * A dependency selector that excludes dependencies of an specific Scope which occur beyond level one of the dependency
+ * graph.
+ * 
+ * @see {@link Dependency#getScope()}
+ * @author Gabriel Belingueres
+ */
+class Maven31DirectScopeDependencySelector
+    implements DependencySelector
+{
+
+    private final String scope;
+
+    private final int depth;
+    
+    private final int hashCode;
+
+    Maven31DirectScopeDependencySelector( String scope )
+    {
+        this( scope, 0 );
+    }
+
+    private Maven31DirectScopeDependencySelector( String scope, int depth )
+    {
+        this.scope = Objects.requireNonNull( scope, "scope is null!" );
+        this.depth = depth;
+        this.hashCode = Objects.hash( scope, depth );
+    }
+
+    /**
+     * Decides whether the specified dependency should be included in the dependency graph.
+     * 
+     * @param dependency The dependency to check, must not be {@code null}.
+     * @return {@code false} if the dependency should be excluded from the children of the current node, {@code true}
+     *         otherwise.
+     */
+    @Override
+    public boolean selectDependency( Dependency dependency )
+    {
+        return depth < 2 || !scope.equals( dependency.getScope() );
+    }
+
+    /**
+     * Derives a dependency selector for the specified collection context. When calculating the child selector,
+     * implementors are strongly advised to simply return the current instance if nothing changed to help save memory.
+     * 
+     * @param context The dependency collection context, must not be {@code null}.
+     * @return The dependency selector for the target node, must not be {@code null}.
+     */
+    @Override
+    public DependencySelector deriveChildSelector( DependencyCollectionContext context )
+    {
+        if ( depth >= 2 )
+        {
+            return this;
+        }
+
+        return new Maven31DirectScopeDependencySelector( scope, depth + 1 );
+    }
+
+    @Override
+    public int hashCode()
+    {
+        return hashCode;
+    }
+
+    @Override
+    public boolean equals( Object obj )
+    {
+        if ( this == obj )
+        {
+            return true;
+        }
+        if ( obj == null )
+        {
+            return false;
+        }
+        if ( getClass() != obj.getClass() )
+        {
+            return false;
+        }
+        Maven31DirectScopeDependencySelector other = (Maven31DirectScopeDependencySelector) obj;
+        if ( depth != other.depth )
+        {
+            return false;
+        }
+        if ( !Objects.equals( scope, other.scope ) )
+        {
+            return false;
+        }
+        return true;
+    }
+
+}
diff --git a/src/main/java/org/apache/maven/shared/transfer/dependencies/collect/internal/MavenDependencyCollector.java b/src/main/java/org/apache/maven/shared/transfer/dependencies/collect/internal/MavenDependencyCollector.java
index ce647f5..7483adc 100644
--- a/src/main/java/org/apache/maven/shared/transfer/dependencies/collect/internal/MavenDependencyCollector.java
+++ b/src/main/java/org/apache/maven/shared/transfer/dependencies/collect/internal/MavenDependencyCollector.java
@@ -41,4 +41,13 @@ interface MavenDependencyCollector
     CollectorResult collectDependencies( Model root )
         throws DependencyCollectorException;
 
+    CollectorResult collectDependenciesGraph( Dependency root )
+        throws DependencyCollectorException;
+
+    CollectorResult collectDependenciesGraph( DependableCoordinate root )
+        throws DependencyCollectorException;
+
+    CollectorResult collectDependenciesGraph( Model root )
+        throws DependencyCollectorException;
+
 }