package com.github.ferstl.depgraph;

import org.apache.maven.artifact.resolver.filter.ArtifactFilter;
import org.apache.maven.plugins.annotations.LifecyclePhase;
import org.apache.maven.plugins.annotations.Mojo;
import org.apache.maven.plugins.annotations.ResolutionScope;
import com.github.ferstl.depgraph.dot.DotBuilder;

/**
 * Creates a graph containing the group IDs of all dependencies.
 */
@Mojo(
    name = "by-groupid",
    aggregator = false,
    defaultPhase = LifecyclePhase.NONE,
    requiresDependencyCollection = ResolutionScope.TEST,
    requiresDirectInvocation = false,
    threadSafe = true)
public class DependencyGraphByGroupIdMojo extends AbstractGraphMojo {

  @Override
  protected GraphFactory createGraphFactory(ArtifactFilter artifactFilter) {
    DotBuilder dotBuilder = new DotBuilder()
        .useNodeRenderer(NodeRenderers.SCOPED_GROUP_ID)
        .useNodeLabelRenderer(NodeRenderers.GROUP_ID_LABEL)
        .omitSelfReferences();

    GraphBuilderAdapter adapter = new GraphBuilderAdapter(this.dependencyGraphBuilder);
    return new SimpleGraphFactory(adapter, artifactFilter, dotBuilder);
  }

}

@@ -205,16 +205,71 @@
 s.Mojo;%0A
+import org.apache.maven.plugins.annotations.Parameter;%0A
 import o
@@ -736,91 +736,1084 @@
 %0A%0A  
-@Override%0A  protected GraphFactory createGraphFactory(ArtifactFilter artifactFilter
+/**%0A   * If set to %7B@code true%7D, the graph will additionally contain conflicting dependencies. Note that the dependency%0A   * graph may not be 100%25 accurate when this flag is enabled and the plugin is executed with a Maven version greater or%0A   * equal 3.0!%0A   *%0A   * @since 1.0.0%0A   */%0A  @Parameter(property = %22showConflicts%22, defaultValue = %22false%22)%0A  boolean showConflicts;%0A%0A  /**%0A   * If set to %7B@code true%7D, the graph will additionally contain duplicate dependencies. Note that the dependency graph%0A   * may not be 100%25 accurate when this flag is enabled and the plugin is executed with a Maven version greater or equal%0A   * 3.0!%0A   *%0A   * @since 1.0.0%0A   */%0A  @Parameter(property = %22showDuplicates%22, defaultValue = %22false%22)%0A  boolean showDuplicates;%0A%0A  @Override%0A  protected GraphFactory createGraphFactory(ArtifactFilter artifactFilter) %7B%0A    DotBuilder dotBuilder = createGraphBuilder();%0A%0A    GraphBuilderAdapter adapter = createGraphBuilderAdapter();%0A    return new SimpleGraphFactory(adapter, artifactFilter, dotBuilder);%0A  %7D%0A%0A  private DotBuilder createGraphBuilder(
 ) %7B%0A
@@ -2009,35 +2009,169 @@
 );%0A%0A    
-GraphBuilderAdapter
+return dotBuilder;%0A  %7D%0A%0A  private GraphBuilderAdapter createGraphBuilderAdapter() %7B%0A    GraphBuilderAdapter adapter;%0A    if (requiresFullGraph()) %7B%0A     
  adapter
@@ -2216,93 +2216,250 @@
 ency
-Graph
+Tree
 Builder
-);%0A    return new SimpleGraphFactory(adapter, artifactFilter, dotBuilder)
+, this.localRepository);%0A    %7D else %7B%0A      adapter = new GraphBuilderAdapter(this.dependencyGraphBuilder);%0A    %7D%0A    return adapter;%0A  %7D%0A%0A  private boolean requiresFullGraph() %7B%0A    return this.showConflicts %7C%7C this.showDuplicates
 ;%0A  

Enable inclusion of duplicate or conflicting dependencies