TreeMojo has a scope parameter (line 122) that is supposed to filter the dependency tree, but it has been non-functional for years due to MSHARED-4 in the maven-dependency-tree library. The TODO at line 232 documents this:
// TODO: note that filter does not get applied due to MSHARED-4
ArtifactFilter artifactFilter = createResolvingArtifactFilter();
The artifactFilter is passed to dependencyCollectorBuilder.collectDependencyGraph() and dependencyGraphBuilder.buildDependencyGraph() at lines 241 and 246, but these methods ignore the filter. This means:
mvn dependency:tree -Dscope=compile
still shows all scopes (test, provided, etc.) with no warning that the filter was not applied.
The fix would be to apply the filter client-side after obtaining the tree, or to fix MSHARED-4 in maven-dependency-tree, or at minimum to log a warning when a scope is specified that it may not be honored.
TreeMojohas ascopeparameter (line 122) that is supposed to filter the dependency tree, but it has been non-functional for years due toMSHARED-4in themaven-dependency-treelibrary. The TODO at line 232 documents this:The
artifactFilteris passed todependencyCollectorBuilder.collectDependencyGraph()anddependencyGraphBuilder.buildDependencyGraph()at lines 241 and 246, but these methods ignore the filter. This means:still shows all scopes (test, provided, etc.) with no warning that the filter was not applied.
The fix would be to apply the filter client-side after obtaining the tree, or to fix MSHARED-4 in maven-dependency-tree, or at minimum to log a warning when a scope is specified that it may not be honored.