In the last post, I wrote about package dependencies. On a higher level, there are project dependencies. In modern Java projects, the number of such dependencies can reach three digit numbers. Keeping track of such an amount is no easy task.
So I had the idea to write a little tool that visualizes the maven dependencies of a project. I thought using the great Graphviz library for it. To my big surprise, the standard maven dependency plugin already provides such a function. Good.
But nevertheless, I played around with maven and Graphviz and the result of it is an interactive dependency browser.
Go to a maven project and execute
mvn guru.nidi.maven.plugins:tools-maven-plugin:1.0.15:dependency. It analyzes the dependencies and creates nice diagrams of it.
The result is visible in a browser at
http://localhost:8888. All displayed projects are clickable so that it’s possible to interactively browse through the whole dependency tree.
These options are available (as maven parameter with
-D<parameter>=<value> or in the URL as query parameters):
maxDepthhow many levels of transient dependencies should be displayed
optionalif optional dependencies should be displayed
scopesa comma separated list of scopes that should be displayed
The URL has the format
http://localhost:8888/<groupId>:<artifactId>:<version>:<packaging>?parameters so it is possible to browse the dependencies of any project that’s in a maven repository.
I don’t know how useful it really is, but it was fun creating the tool and browsing through maven.