Am trying to generate dependency tree in maven, making use of below command
$ mvn dependency:tree -DoutputType=dot
Output looks like below
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building test 1.0
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-dependency-plugin:2.8:tree (default-cli) @ test ---
[INFO] digraph "com.a:test:jar:1.0" {
[INFO] "com.a:test:jar:1.0" -> "org.apache.httpcomponents:httpclient:jar:4.5.5:compile" ;
[INFO] "com.a:test:jar:1.0" -> "com.google.code.gson:gson:jar:2.8.2:compile" ;
[INFO] "com.a:test:jar:1.0" -> "info.picocli:picocli:jar:2.3.0:compile" ;
[INFO] "com.a:test:jar:1.0" -> "log4j:log4j:jar:1.2.17:compile" ;
[INFO] "com.a:test:jar:1.0" -> "org.xerial:sqlite-jdbc:jar:3.21.0:compile" ;
[INFO] "org.apache.httpcomponents:httpclient:jar:4.5.5:compile" -> "org.apache.httpcomponents:httpcore:jar:4.4.9:compile" ;
[INFO] "org.apache.httpcomponents:httpclient:jar:4.5.5:compile" -> "commons-logging:commons-logging:jar:1.2:compile" ;
[INFO] "org.apache.httpcomponents:httpclient:jar:4.5.5:compile" -> "commons-codec:commons-codec:jar:1.10:compile" ;
[INFO] }
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
It has both direct and transitive dependencies, what i am expecting is just direct one , can making use of grep
or some flags -Dexcludes
helps to achieve below output
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building test 1.0
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-dependency-plugin:2.8:tree (default-cli) @ test ---
[INFO] digraph "com.a:test:jar:1.0" {
[INFO] "com.a:test:jar:1.0" -> "org.apache.httpcomponents:httpclient:jar:4.5.5:compile" ;
[INFO] "com.a:test:jar:1.0" -> "com.google.code.gson:gson:jar:2.8.2:compile" ;
[INFO] "com.a:test:jar:1.0" -> "info.picocli:picocli:jar:2.3.0:compile" ;
[INFO] "com.a:test:jar:1.0" -> "log4j:log4j:jar:1.2.17:compile" ;
[INFO] "com.a:test:jar:1.0" -> "org.xerial:sqlite-jdbc:jar:3.21.0:compile" ;
[INFO] }
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
Am expecting something like npm ls --depth=0
as in node ecosystem, were depth flags helps to just get direct dependencies.
Note: i can't make use of dependency:list
as i need above structure.