2323import java .io .StringWriter ;
2424import java .io .Writer ;
2525import java .util .ArrayList ;
26- import java .util .Arrays ;
2726import java .util .List ;
2827import java .util .Objects ;
2928
5756import org .apache .maven .shared .dependency .graph .traversal .FilteringDependencyNodeVisitor ;
5857import org .apache .maven .shared .dependency .graph .traversal .SerializingDependencyNodeVisitor ;
5958import org .apache .maven .shared .dependency .graph .traversal .SerializingDependencyNodeVisitor .GraphTokens ;
60- import org .eclipse .aether .RepositorySystem ;
61- import org .eclipse .aether .RepositorySystemSession ;
62- import org .eclipse .aether .repository .RemoteRepository ;
6359
6460/**
6561 * Displays the dependency tree for this project. Multiple formats are supported: text (by default), but also
6662 * <a href="https://en.wikipedia.org/wiki/DOT_language">DOT</a>,
67- * <a href="https://en.wikipedia.org/wiki/GraphML">GraphML</a>, and
68- * <a href="https://en.wikipedia.org/wiki/Trivial_Graph_Format">TGF</a>.
63+ * <a href="https://en.wikipedia.org/wiki/GraphML">GraphML</a>,
64+ * <a href="https://en.wikipedia.org/wiki/Trivial_Graph_Format">TGF</a> and
65+ * <a href="https://en.wikipedia.org/wiki/JSON">JSON</a>.
66+ *
6967 *
7068 * @author <a href="mailto:[email protected] ">Mark Hobson</a> 7169 * @since 2.0-alpha-5
@@ -86,30 +84,6 @@ public class TreeMojo extends AbstractMojo {
8684 @ Parameter (property = "outputEncoding" , defaultValue = "${project.reporting.outputEncoding}" )
8785 private String outputEncoding ;
8886
89- /**
90- * Contains the full list of projects in the reactor.
91- */
92- @ Parameter (defaultValue = "${reactorProjects}" , readonly = true , required = true )
93- private List <MavenProject > reactorProjects ;
94-
95- @ Component
96- private RepositorySystem repositorySystem ;
97-
98- @ Parameter (defaultValue = "${repositorySystem}" )
99- RepositorySystem repositorySystemParam ;
100-
101- /**
102- * The current repository/network configuration of Maven.
103- */
104- @ Parameter (defaultValue = "${repositorySystemSession}" )
105- private RepositorySystemSession repoSession ;
106-
107- /**
108- * The project's remote repositories to use for the resolution of project dependencies.
109- */
110- @ Parameter (defaultValue = "${project.remoteProjectRepositories}" )
111- private List <RemoteRepository > projectRepos ;
112-
11387 /**
11488 * The dependency collector builder to use.
11589 */
@@ -133,7 +107,8 @@ public class TreeMojo extends AbstractMojo {
133107
134108 /**
135109 * If specified, this parameter will cause the dependency tree to be written using the specified format. Currently
136- * supported format are: <code>text</code> (default), <code>dot</code>, <code>graphml</code> and <code>tgf</code>.
110+ * supported formats are: <code>text</code> (default), <code>dot</code>, <code>graphml</code>, <code>tgf</code>
111+ * and <code>json</code>.
137112 * These additional formats can be plotted to image files.
138113 *
139114 * @since 2.2
@@ -187,7 +162,7 @@ public class TreeMojo extends AbstractMojo {
187162 * @since 2.0-alpha-6
188163 */
189164 @ Parameter (property = "includes" )
190- private String includes ;
165+ private List < String > includes ;
191166
192167 /**
193168 * A comma-separated list of artifacts to filter from the serialized dependency tree, or <code>null</code> not to
@@ -208,7 +183,7 @@ public class TreeMojo extends AbstractMojo {
208183 * @since 2.0-alpha-6
209184 */
210185 @ Parameter (property = "excludes" )
211- private String excludes ;
186+ private List < String > excludes ;
212187
213188 /**
214189 * The computed dependency tree root node of the Maven project.
@@ -417,22 +392,20 @@ private DependencyNodeFilter createDependencyNodeFilter() {
417392 List <DependencyNodeFilter > filters = new ArrayList <>();
418393
419394 // filter includes
420- if (includes != null ) {
421- List <String > patterns = Arrays .asList (includes .split ("," ));
395+ if (includes != null && !includes .isEmpty ()) {
422396
423- getLog ().debug ("+ Filtering dependency tree by artifact include patterns: " + patterns );
397+ getLog ().debug ("+ Filtering dependency tree by artifact include patterns: " + includes );
424398
425- ArtifactFilter artifactFilter = new StrictPatternIncludesArtifactFilter (patterns );
399+ ArtifactFilter artifactFilter = new StrictPatternIncludesArtifactFilter (includes );
426400 filters .add (new ArtifactDependencyNodeFilter (artifactFilter ));
427401 }
428402
429403 // filter excludes
430- if (excludes != null ) {
431- List <String > patterns = Arrays .asList (excludes .split ("," ));
404+ if (excludes != null && !excludes .isEmpty ()) {
432405
433- getLog ().debug ("+ Filtering dependency tree by artifact exclude patterns: " + patterns );
406+ getLog ().debug ("+ Filtering dependency tree by artifact exclude patterns: " + excludes );
434407
435- ArtifactFilter artifactFilter = new StrictPatternExcludesArtifactFilter (patterns );
408+ ArtifactFilter artifactFilter = new StrictPatternExcludesArtifactFilter (excludes );
436409 filters .add (new ArtifactDependencyNodeFilter (artifactFilter ));
437410 }
438411
0 commit comments