How to generate a graph of the dependency between all modules of a Maven project (excluding third party libraries like JUnit, SLF4J, etc.)? I couldn't find a way to include all modules into one graph using m2eclipse. Thanks.
如何生成Maven项目的所有模块之间的依赖关系图(不包括第三方库,如JUnit,SLF4J等)?我找不到使用m2eclipse将所有模块包含到一个图形中的方法。谢谢。
8 个解决方案
#1
25
If the Dependency Graph feature of m2eclipse doesn't cover your needs, maybe have a look at the Maven Graph Plugin and in particular its graph:reactor
goal.
如果m2eclipse的依赖关系图功能不能满足您的需求,可以查看Maven Graph插件,特别是它的图:reactor目标。
UPDATE: the Dependency Graph feature was removed in m2eclipse 1.0. For more info see: Maven POM-Editor: Dependency Graph missing
更新:m2eclipse 1.0中删除了依赖关系图功能。有关详细信息,请参阅:Maven POM-Editor:缺少依赖关系图
#2
9
Another option is the com.github.janssk1 maven dependency graph plugin. This plugin outputs the dependencies to a graphml file which can be opened and edited in an editor like yEd.
另一个选项是com.github.janssk1 maven依赖图插件。此插件将依赖项输出到graphml文件,该文件可以在yEd等编辑器中打开和编辑。
To generate the graphml file:
要生成graphml文件:
mvn com.github.janssk1:maven-dependencygraph-plugin:1.0:graph
This plugin does not currently provide any mechanism to exclude 3rd party dependencies, AFAICT, but they can be deleted manually from the graph using yEd or via an XSLT stylesheet that post-processes the graphml files. Here is a simple stylesheet that will delete the third party dependencies (any dependency not starting with the package provided by the "internal" parameter):
此插件目前不提供排除第三方依赖项AFAICT的任何机制,但可以使用yEd或通过后处理graphml文件的XSLT样式表从图中手动删除它们。这是一个简单的样式表,它将删除第三方依赖项(任何依赖项不以“internal”参数提供的包开头):
<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:gml="http://graphml.graphdrawing.org/xmlns/graphml"
version="2.0">
<xsl:output method="xml"/>
<xsl:param name="internal"/>
<xsl:template match="@*|node()">
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
</xsl:template>
<xsl:template match="gml:node[not(starts-with(@id, $internal))]"/>
<xsl:template match="gml:edge[not(starts-with(@source, $internal)) or not(starts-with(@target, $internal))]"/>
</xsl:stylesheet>
And execute it via an XSLT 2.0 compatible processor such as Saxon:
并通过兼容XSLT 2.0的处理器(如Saxon)执行:
saxon input.graphml exclude-third-party-deps.xsl internal="my.package" > input-internal.graphml
#3
6
there exists exactly what you need, it is called Pom Explorer.
存在你需要的东西,它被称为Pom Explorer。
You can find the website here : github.com/ltearno/pom-explorer
你可以在这里找到这个网站:github.com/ltearno/pom-explorer
It is a tool to work on a graph of maven projects. As a teaser i can say that on my machine it analyzes 4000 pom.xml files in 4 seconds. Then many functionnalities are provided above the analysed pom graph :
它是一个处理maven项目图的工具。作为预告片我可以说在我的机器上它在4秒内分析了4000个pom.xml文件。然后在分析的pom图上方提供了许多功能:
- dependency analysis (who depends on GAV, which gavs this GAV depends on, with transitivity),
- 依赖性分析(依赖于GAV,GAV依赖于GAV,具有传递性),
- resolution (pom explorer knows where are defined properties, it manages dependencies and bom imports),
- 解决方案(pom explorer知道定义的属性在哪里,它管理依赖关系和bom导入),
- manipulation (you can use it to transform you pom graph, let's say if you want many projects to use a new version of a dependency),
- 操作(您可以使用它来转换pom图,假设您希望许多项目使用新版本的依赖项),
- build (pom explorer analyses your pom graph and knows in which order they should be built, then it builds everything ! it can even watch your projects directories for change),
- 构建(pom explorer分析你的pom图并知道它们应该构建的顺序,然后它构建所有东西!它甚至可以监视你的项目目录以进行更改),
- exporting (today there is CSV and a GRAPHML exports),
- 导出(今天有CSV和GRAPHML导出),
- visualization (pom explorer can show you an interactive 3D customizable visualization of your projects graph).
- 可视化(pom explorer可以向您显示项目图形的交互式3D可自定义可视化)。
It is in active development right now so don't hesitate to try it, report bugs and ask for useful features ! The documentation is also not complete yet, so again don't hesitate to ask !
它正在积极开发中,所以不要犹豫,尝试它,报告错误并要求有用的功能!文档还没有完成,所以再次不要犹豫!
Thanks
谢谢
#4
5
Checkout this project too: https://github.com/roclas/pomParser
也可以查看这个项目:https://github.com/roclas/pomParser
It creates a pretty cool "graph" that can be navigated in both ways (forwards and backwards). The idea is very simple, and you can download and change the code very easily.
它创建了一个非常酷的“图形”,可以以两种方式(向前和向后)进行导航。这个想法非常简单,您可以非常轻松地下载和更改代码。
#5
3
Installed Maven Graph Plugin: http://mvnplugins.fusesource.org/maven/1.10/maven-graph-plugin/index.html, configured it this way to hide third party dependencies. Worked out fine.
已安装的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>
#6
2
Haven't you opened the pom via Eclipse and taken a look onto the tab-folders of the pom.xml where one entry is name "Dependency Graph" ? Ah sorry...oversight something...You can create a dependency tree via mvn dependency:tree on command line, but this produces no graphical view. An other better solution might be the Maven Overview Plugin
你有没有通过Eclipse打开pom并查看pom.xml的tab-folders,其中一个条目名为“Dependency Graph”?对不起......疏忽了......你可以通过命令行上的mvn依赖:树创建依赖树,但这不会产生图形视图。另一个更好的解决方案可能是Maven概述插件
#7
0
I also created a tool for this. I spent the day hacking on it so still very experimental =) Testing and code contributions are welcome!
我还为此创建了一个工具。我花了一天时间黑客攻击它仍然非常实验性=)测试和代码贡献是受欢迎的!
I call it Maven Repository Dependency Visualizer. It does not only show dependencies, but all involved artifacts.
我称之为Maven Repository Dependency Visualizer。它不仅显示依赖关系,还显示所有涉及的工件。
With this input:
有了这个输入:
java -jar build/libs/maven-repository-dependency-visualizer-*-SNAPSHOT.jar \
-r http://repo1.maven.org/maven2 \
-fgs se.bjurr.violations \
-g se.bjurr.violations \
-a violation-comments-to-gitlab-gradle-plugin \
-v 1.9
- A repository, like Nexus or Artifactory.
- 存储库,如Nexus或Artifactory。
- One, or more, groups to include.
- 一个或多个要包括的组。
- A group, artifact and version.
- 组,工件和版本。
It will output a graph showing relations between all artifacts that:
它将输出一个图表,显示所有工件之间的关系:
- The given artifact depends on.
- 给定的工件取决于。
- Depend on the given artifact.
- 取决于给定的工件。
- Depend on on any artifact that the given artifact depends on.
- 取决于给定工件所依赖的任何工件。
It can be used to:
它可以用于:
- Quick understanding of the software being developed by an organization.
- 快速了解组织正在开发的软件。
- Determine how delivery pipelines should be designed.
- 确定应如何设计交付管道。
- Find strange dependencies between artifacts.
- 找出工件之间的奇怪依赖关系。
- And much more =)
- 还有更多=)
It is available on GitHub.
它可以在GitHub上找到。
#8
0
This might be good enough for some people:
这对某些人来说可能已经足够了:
- https://maven.apache.org/plugins/maven-dependency-plugin/examples/filtering-the-dependency-tree.html
- https://maven.apache.org/plugins/maven-dependency-plugin/examples/filtering-the-dependency-tree.html
Command: mvn dependency:tree -Dincludes=com.yourpackage:*
命令:mvn依赖:tree -Dincludes = com.yourpackage:*
#1
25
If the Dependency Graph feature of m2eclipse doesn't cover your needs, maybe have a look at the Maven Graph Plugin and in particular its graph:reactor
goal.
如果m2eclipse的依赖关系图功能不能满足您的需求,可以查看Maven Graph插件,特别是它的图:reactor目标。
UPDATE: the Dependency Graph feature was removed in m2eclipse 1.0. For more info see: Maven POM-Editor: Dependency Graph missing
更新:m2eclipse 1.0中删除了依赖关系图功能。有关详细信息,请参阅:Maven POM-Editor:缺少依赖关系图
#2
9
Another option is the com.github.janssk1 maven dependency graph plugin. This plugin outputs the dependencies to a graphml file which can be opened and edited in an editor like yEd.
另一个选项是com.github.janssk1 maven依赖图插件。此插件将依赖项输出到graphml文件,该文件可以在yEd等编辑器中打开和编辑。
To generate the graphml file:
要生成graphml文件:
mvn com.github.janssk1:maven-dependencygraph-plugin:1.0:graph
This plugin does not currently provide any mechanism to exclude 3rd party dependencies, AFAICT, but they can be deleted manually from the graph using yEd or via an XSLT stylesheet that post-processes the graphml files. Here is a simple stylesheet that will delete the third party dependencies (any dependency not starting with the package provided by the "internal" parameter):
此插件目前不提供排除第三方依赖项AFAICT的任何机制,但可以使用yEd或通过后处理graphml文件的XSLT样式表从图中手动删除它们。这是一个简单的样式表,它将删除第三方依赖项(任何依赖项不以“internal”参数提供的包开头):
<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:gml="http://graphml.graphdrawing.org/xmlns/graphml"
version="2.0">
<xsl:output method="xml"/>
<xsl:param name="internal"/>
<xsl:template match="@*|node()">
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
</xsl:template>
<xsl:template match="gml:node[not(starts-with(@id, $internal))]"/>
<xsl:template match="gml:edge[not(starts-with(@source, $internal)) or not(starts-with(@target, $internal))]"/>
</xsl:stylesheet>
And execute it via an XSLT 2.0 compatible processor such as Saxon:
并通过兼容XSLT 2.0的处理器(如Saxon)执行:
saxon input.graphml exclude-third-party-deps.xsl internal="my.package" > input-internal.graphml
#3
6
there exists exactly what you need, it is called Pom Explorer.
存在你需要的东西,它被称为Pom Explorer。
You can find the website here : github.com/ltearno/pom-explorer
你可以在这里找到这个网站:github.com/ltearno/pom-explorer
It is a tool to work on a graph of maven projects. As a teaser i can say that on my machine it analyzes 4000 pom.xml files in 4 seconds. Then many functionnalities are provided above the analysed pom graph :
它是一个处理maven项目图的工具。作为预告片我可以说在我的机器上它在4秒内分析了4000个pom.xml文件。然后在分析的pom图上方提供了许多功能:
- dependency analysis (who depends on GAV, which gavs this GAV depends on, with transitivity),
- 依赖性分析(依赖于GAV,GAV依赖于GAV,具有传递性),
- resolution (pom explorer knows where are defined properties, it manages dependencies and bom imports),
- 解决方案(pom explorer知道定义的属性在哪里,它管理依赖关系和bom导入),
- manipulation (you can use it to transform you pom graph, let's say if you want many projects to use a new version of a dependency),
- 操作(您可以使用它来转换pom图,假设您希望许多项目使用新版本的依赖项),
- build (pom explorer analyses your pom graph and knows in which order they should be built, then it builds everything ! it can even watch your projects directories for change),
- 构建(pom explorer分析你的pom图并知道它们应该构建的顺序,然后它构建所有东西!它甚至可以监视你的项目目录以进行更改),
- exporting (today there is CSV and a GRAPHML exports),
- 导出(今天有CSV和GRAPHML导出),
- visualization (pom explorer can show you an interactive 3D customizable visualization of your projects graph).
- 可视化(pom explorer可以向您显示项目图形的交互式3D可自定义可视化)。
It is in active development right now so don't hesitate to try it, report bugs and ask for useful features ! The documentation is also not complete yet, so again don't hesitate to ask !
它正在积极开发中,所以不要犹豫,尝试它,报告错误并要求有用的功能!文档还没有完成,所以再次不要犹豫!
Thanks
谢谢
#4
5
Checkout this project too: https://github.com/roclas/pomParser
也可以查看这个项目:https://github.com/roclas/pomParser
It creates a pretty cool "graph" that can be navigated in both ways (forwards and backwards). The idea is very simple, and you can download and change the code very easily.
它创建了一个非常酷的“图形”,可以以两种方式(向前和向后)进行导航。这个想法非常简单,您可以非常轻松地下载和更改代码。
#5
3
Installed Maven Graph Plugin: http://mvnplugins.fusesource.org/maven/1.10/maven-graph-plugin/index.html, configured it this way to hide third party dependencies. Worked out fine.
已安装的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>
#6
2
Haven't you opened the pom via Eclipse and taken a look onto the tab-folders of the pom.xml where one entry is name "Dependency Graph" ? Ah sorry...oversight something...You can create a dependency tree via mvn dependency:tree on command line, but this produces no graphical view. An other better solution might be the Maven Overview Plugin
你有没有通过Eclipse打开pom并查看pom.xml的tab-folders,其中一个条目名为“Dependency Graph”?对不起......疏忽了......你可以通过命令行上的mvn依赖:树创建依赖树,但这不会产生图形视图。另一个更好的解决方案可能是Maven概述插件
#7
0
I also created a tool for this. I spent the day hacking on it so still very experimental =) Testing and code contributions are welcome!
我还为此创建了一个工具。我花了一天时间黑客攻击它仍然非常实验性=)测试和代码贡献是受欢迎的!
I call it Maven Repository Dependency Visualizer. It does not only show dependencies, but all involved artifacts.
我称之为Maven Repository Dependency Visualizer。它不仅显示依赖关系,还显示所有涉及的工件。
With this input:
有了这个输入:
java -jar build/libs/maven-repository-dependency-visualizer-*-SNAPSHOT.jar \
-r http://repo1.maven.org/maven2 \
-fgs se.bjurr.violations \
-g se.bjurr.violations \
-a violation-comments-to-gitlab-gradle-plugin \
-v 1.9
- A repository, like Nexus or Artifactory.
- 存储库,如Nexus或Artifactory。
- One, or more, groups to include.
- 一个或多个要包括的组。
- A group, artifact and version.
- 组,工件和版本。
It will output a graph showing relations between all artifacts that:
它将输出一个图表,显示所有工件之间的关系:
- The given artifact depends on.
- 给定的工件取决于。
- Depend on the given artifact.
- 取决于给定的工件。
- Depend on on any artifact that the given artifact depends on.
- 取决于给定工件所依赖的任何工件。
It can be used to:
它可以用于:
- Quick understanding of the software being developed by an organization.
- 快速了解组织正在开发的软件。
- Determine how delivery pipelines should be designed.
- 确定应如何设计交付管道。
- Find strange dependencies between artifacts.
- 找出工件之间的奇怪依赖关系。
- And much more =)
- 还有更多=)
It is available on GitHub.
它可以在GitHub上找到。
#8
0
This might be good enough for some people:
这对某些人来说可能已经足够了:
- https://maven.apache.org/plugins/maven-dependency-plugin/examples/filtering-the-dependency-tree.html
- https://maven.apache.org/plugins/maven-dependency-plugin/examples/filtering-the-dependency-tree.html
Command: mvn dependency:tree -Dincludes=com.yourpackage:*
命令:mvn依赖:tree -Dincludes = com.yourpackage:*