I wanted to have a diagram of Maven dependencies but just the ones with a certain groupId should be included. I do not know whether the m2e Eclipse plugin provided such a feature but with release 1.0 the dependency diagram feature was removed. IntelliJ IDEA Ultimate has a nice dependency diagram but you cannot filter for certain dependencies just for scope.
O.k. Back to the roots. My idea was
- to use the tree goal of the Maven dependency plugin
- and then filter just the dependencies I am interested in with grep
- and then convert it somehow to a format yEd can read
- Finally use yEd auto layout to make a nice diagram
Thanks to the Maven dependency plugin this was much easier because
- it supports filtering of the dependency tree
- and it can directly generate .graphml-files
mvn org.apache.maven.plugins:maven-dependency-plugin:2.4:tree -DoutputFile=/tmp/cocoon-all.graphml -DoutputType=graphml -Dverbose=true
To include just the dependencies with groupId org.apache.cocoon.*:
mvn org.apache.maven.plugins:maven-dependency-plugin:2.4:tree -Dinclues=org.apache.cocoon.* -DoutputFile=/tmp/cocoon-all_only-org.apache.cocoon.graphml -DoutputType=graphml -Dverbose=true
In yEd you can simply
- select all nodes
- change the width of all nodes at once
- and then use the tree automatic layout
to get a nice looking diagram.
If you don’t want to see the scope compile at the edges you can simply process the .graphml-file with sed:
sed ‘s/compile<\/y:EdgeLabel>/<\/y:EdgeLabel>/g’ /tmp/cocoon-all_only-org.apache.cocoon.graphml >/tmp/cocoon-all_only-org.apache.cocoon_no-compile-edge-labels.graphml
Great! I generated the customized dependency diagram I needed with freely available tools! Thanks to Maven dependency plugin and yEd!
Thanks for reading. Feedback welcome on your experience with Maven dependency diagrams.