23
23
import java .io .StringWriter ;
24
24
import java .io .Writer ;
25
25
import java .util .ArrayList ;
26
- import java .util .Arrays ;
27
26
import java .util .List ;
28
27
import java .util .Objects ;
29
28
57
56
import org .apache .maven .shared .dependency .graph .traversal .FilteringDependencyNodeVisitor ;
58
57
import org .apache .maven .shared .dependency .graph .traversal .SerializingDependencyNodeVisitor ;
59
58
import 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 ;
63
59
64
60
/**
65
61
* Displays the dependency tree for this project. Multiple formats are supported: text (by default), but also
66
62
* <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
+ *
69
67
*
70
68
* @author <a href="mailto:markhobson@gmail.com">Mark Hobson</a>
71
69
* @since 2.0-alpha-5
@@ -86,30 +84,6 @@ public class TreeMojo extends AbstractMojo {
86
84
@ Parameter (property = "outputEncoding" , defaultValue = "${project.reporting.outputEncoding}" )
87
85
private String outputEncoding ;
88
86
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
-
113
87
/**
114
88
* The dependency collector builder to use.
115
89
*/
@@ -133,7 +107,8 @@ public class TreeMojo extends AbstractMojo {
133
107
134
108
/**
135
109
* 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>.
137
112
* These additional formats can be plotted to image files.
138
113
*
139
114
* @since 2.2
@@ -187,7 +162,7 @@ public class TreeMojo extends AbstractMojo {
187
162
* @since 2.0-alpha-6
188
163
*/
189
164
@ Parameter (property = "includes" )
190
- private String includes ;
165
+ private List < String > includes ;
191
166
192
167
/**
193
168
* 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 {
208
183
* @since 2.0-alpha-6
209
184
*/
210
185
@ Parameter (property = "excludes" )
211
- private String excludes ;
186
+ private List < String > excludes ;
212
187
213
188
/**
214
189
* The computed dependency tree root node of the Maven project.
@@ -417,22 +392,20 @@ private DependencyNodeFilter createDependencyNodeFilter() {
417
392
List <DependencyNodeFilter > filters = new ArrayList <>();
418
393
419
394
// filter includes
420
- if (includes != null ) {
421
- List <String > patterns = Arrays .asList (includes .split ("," ));
395
+ if (includes != null && !includes .isEmpty ()) {
422
396
423
- getLog ().debug ("+ Filtering dependency tree by artifact include patterns: " + patterns );
397
+ getLog ().debug ("+ Filtering dependency tree by artifact include patterns: " + includes );
424
398
425
- ArtifactFilter artifactFilter = new StrictPatternIncludesArtifactFilter (patterns );
399
+ ArtifactFilter artifactFilter = new StrictPatternIncludesArtifactFilter (includes );
426
400
filters .add (new ArtifactDependencyNodeFilter (artifactFilter ));
427
401
}
428
402
429
403
// filter excludes
430
- if (excludes != null ) {
431
- List <String > patterns = Arrays .asList (excludes .split ("," ));
404
+ if (excludes != null && !excludes .isEmpty ()) {
432
405
433
- getLog ().debug ("+ Filtering dependency tree by artifact exclude patterns: " + patterns );
406
+ getLog ().debug ("+ Filtering dependency tree by artifact exclude patterns: " + excludes );
434
407
435
- ArtifactFilter artifactFilter = new StrictPatternExcludesArtifactFilter (patterns );
408
+ ArtifactFilter artifactFilter = new StrictPatternExcludesArtifactFilter (excludes );
436
409
filters .add (new ArtifactDependencyNodeFilter (artifactFilter ));
437
410
}
438
411
0 commit comments