我的项目由几个模块组成,这些模块彼此依赖,并且记住依赖于什么的并不是那么简单,因此我希望可视化依赖图。
我知道有可能以依赖关系的点格式创建文本描述:
mvn dependency:tree -Dincludes=ch.sahits.game -DappendOutput=true
-DoutputType=dot -DappendOutput=true
-DoutputFile=output.dot
这将在每个模块中生成output.dot文件。由于基本上有一个模块可以收集所有其他模块,我只想查看那个模块,它看起来像这样:
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" ;
}
出于我的目的,它不完整,因为它例如忽略OpenPatricianJavaFX
对OpenPatricianImage
的依赖关系。为了解决这个问题,我四处搜集了所有丢失的信息,以便我可以使用graphviz生成图形图像:
dot -Tpng output.dot -o dependencies.png
结果是一团糟,虽然它是正确的表示,但它没有帮助记录依赖项。 有一些帖子解决了同样的问题,但它们都有点过时了:
所以我的问题归结为对这两个步骤的建议:
maven-dependency-plugin
?