如何生成Maven项目的所有模块之间的依赖关系图?

时间:2010-11-03 06:26:47

标签: java maven-2

如何生成Maven项目的所有模块之间的依赖关系图(不包括第三方库,如JUnit,SLF4J等)?我找不到使用m2eclipse将所有模块包含到一个图中的方法。感谢。

7 个答案:

答案 0 :(得分:28)

如果m2eclipse的依赖关系图功能无法满足您的需求,请查看Maven Graph Plugin,特别是其graph:reactor目标。

更新:m2eclipse 1.0 中删除了依赖关系图功能。有关详细信息,请参阅:Maven POM-Editor: Dependency Graph missing

答案 1 :(得分:6)

确切存在您需要的内容,它被称为 Pom Explorer

您可以在此处找到该网站:github.com/ltearno/pom-explorer

这是一个处理maven项目图表的工具。作为预告片我可以说在我的机器上它在4秒内分析了4000个pom.xml文件。然后在分析的pom图上方提供了许多功能:

  • 依赖性分析(依赖于GAV,GAV依赖于GAV,具有传递性),
  • 解析(pom explorer知道定义的属性在哪里,它管理依赖关系和bom导入),
  • 操作(您可以使用它来转换pom图,假设您希望许多项目使用新版本的依赖项),
  • build(pom explorer分析你的pom图并知道它们应该以什么顺序构建,然后它构建所有内容!它甚至可以监视你的项目目录以进行更改),
  • 导出(今天有CSV和GRAPHML导出),
  • 可视化(pom explorer可以向您显示项目图形的交互式3D可自定义可视化)。

现在正在积极开发中,所以不要犹豫,尝试它,报告错误并要求有用的功能!文档还没有完成,所以再次不要犹豫!

由于

答案 2 :(得分:5)

也检查这个项目: https://github.com/roclas/pomParser

它创建了一个非常酷的“图形”,可以以两种方式(向前和向后)导航。 这个想法非常简单,您可以非常轻松地下载和更改代码。

答案 3 :(得分:3)

已安装的Maven图形插件:http://mvnplugins.fusesource.org/maven/1.10/maven-graph-plugin/index.html,以这种方式配置它以隐藏第三方依赖项。工作得很好。

 <profile>
  <id>graph</id>
  <pluginRepositories>
    <pluginRepository>
      <id>mvnplugins.fusesource.org</id>
      <url>http://mvnplugins.fusesource.org/repo/release</url>
      <releases>
        <enabled>true</enabled>
      </releases>
    </pluginRepository>
  </pluginRepositories>
  <build>
    <plugins>
      <plugin>
        <groupId>org.fusesource.mvnplugins</groupId>
        <artifactId>maven-graph-plugin</artifactId>
        <version>1.10</version>

        <configuration>
          <hideExternal>true</hideExternal>
        </configuration>

      </plugin>
    </plugins>
  </build>
</profile>

答案 4 :(得分:2)

你有没有通过Eclipse打开pom并查看pom.xml的tab-folders,其中一个条目名为"Dependency Graph"? 对不起......疏忽了......你可以通过命令行上的mvn依赖:树创建依赖树,但这不会产生图形视图。另一个更好的解决方案可能是Maven Overview Plugin

答案 5 :(得分:1)

刚发现这一点,效果很好,很多输出格式和过滤方式:https://github.com/ferstl/depgraph-maven-plugin

使用该答案,问题的答案就变成了一条直线(可在this helpful blog entry中找到:

mvn com.github.ferstl:depgraph-maven-plugin:3.0.1:aggregate -DcreateImage=true -DreduceEdges=false -Dscope=compile "-Dincludes=your.group.id*:*"

答案 6 :(得分:0)

这对某些人来说可能已经足够了:

命令:mvn依赖:tree -Dincludes = com.yourpackage:*