My project is composed of several modules, which depend on each other and it is not that simple to keep in mind what depends on what, therefore I wanted to have the dependency graph visualized.
I am aware of the possibility to create a textual description in dot format of the dependencies:
mvn dependency:tree -Dincludes=ch.sahits.game -DappendOutput=true
-DoutputType=dot -DappendOutput=true
-DoutputFile=output.dot
This will generate output.dot files in each module. As there is basically one module that collects all others, I only want to look at that one and it looks like this:
digraph "ch.sahits.game:OpenPatricianDisplay:jar:0.8.0-SNAPSHOT" {
"ch.sahits.game:OpenPatricianDisplay:jar:0.8.0-SNAPSHOT" -> "ch.sahits.game:OpenPatricianImage:jar:0.8.0-SNAPSHOT:compile" ;
"ch.sahits.game:OpenPatricianDisplay:jar:0.8.0-SNAPSHOT" -> "ch.sahits.game:OpenPatricianData:jar:0.8.0-SNAPSHOT:compile" ;
"ch.sahits.game:OpenPatricianDisplay:jar:0.8.0-SNAPSHOT" -> "ch.sahits.game:OpenPatricianSound:jar:0.8.0-SNAPSHOT:compile" ;
"ch.sahits.game:OpenPatricianDisplay:jar:0.8.0-SNAPSHOT" -> "ch.sahits.game:OpenPatricianJavaFX:jar:0.8.0-SNAPSHOT:compile" ;
"ch.sahits.game:OpenPatricianDisplay:jar:0.8.0-SNAPSHOT" -> "ch.sahits.game:MarvinFXEssentials:jar:0.8.0-SNAPSHOT:test" ;
"ch.sahits.game:OpenPatricianDisplay:jar:0.8.0-SNAPSHOT" -> "ch.sahits.game:OpenPatricianServer:jar:0.8.0-SNAPSHOT:compile" ;
"ch.sahits.game:OpenPatricianImage:jar:0.8.0-SNAPSHOT:compile" -> "ch.sahits.game:OpenPatricianModel:jar:0.8.0-SNAPSHOT:compile" ;
"ch.sahits.game:OpenPatricianModel:jar:0.8.0-SNAPSHOT:compile" -> "ch.sahits.game:GameEvent:jar:0.8.0-SNAPSHOT:compile" ;
"ch.sahits.game:OpenPatricianSound:jar:0.8.0-SNAPSHOT:compile" -> "ch.sahits.game:OpenPatricianUtilities:jar:0.8.0-SNAPSHOT:compile" ;
"ch.sahits.game:OpenPatricianJavaFX:jar:0.8.0-SNAPSHOT:compile" -> "ch.sahits.game:OpenPatricianGameEvent:jar:0.8.0-SNAPSHOT:compile" ;
"ch.sahits.game:OpenPatricianGameEvent:jar:0.8.0-SNAPSHOT:compile" -> "ch.sahits.game:OpenPatricianClientServerInterface:jar:0.8.0-SNAPSHOT:compile" ;
"ch.sahits.game:OpenPatricianServer:jar:0.8.0-SNAPSHOT:compile" -> "ch.sahits.game:OpenPatricianEngine:jar:0.8.0-SNAPSHOT:compile" ;
}
For my purposes however it is incomplete, as it for example ignores dependencies of the OpenPatricianJavaFX
on OpenPatricianImage
. To remedy that I went around and collected all the missing information, so that I then could generate the graph image with graphviz:
dot -Tpng output.dot -o dependencies.png
The result is a mess, while it is correct representation it is no help in documenting the dependencies.
There are some posts addressing the same issue, but they are all a bit dated:
- How to generate a graph of the dependency between all modules of a Maven project? provides as solution based on Eclipse and it seems that particular plugin no longer exists.
- Maven dependency graph basically describes the same approach I have chosen. This post does as well with a bit more details.
- A Visual Maven Dependency Tree View is probably the plugin mentioned in the first point.
- Maven Dependencies Diagram looks like the perfect solution for IntelliJ, but I cannot find that plug-in anywhere.
So my question boils down to advice on the two steps:
- Generate a model of the dependencies within my project while ignoring third party dependencies: Is there another/better way than the
maven-dependency-plugin
? - How to generate a readable diagram from the output of step 1)? Possible option would also include some way manually adjust the layout before it is exported to an image.