在 maven dependency:tree 中显示省略的版本?
Display omitted versions in maven dependency:tree?
在 Eclipse 中,当我转到 Maven Dependency Hierarchy 页面时,我得到的输出说明是什么冲突导致版本被省略:
但是,如果我使用 dependency:tree,那将被忽略,我只看到实际使用的版本:
| +- commons-httpclient:commons-httpclient:jar:3.1:compile
| +- commons-codec:commons-codec:jar:1.4:compile
| +- commons-io:commons-io:jar:2.4:compile
| +- commons-net:commons-net:jar:3.1:compile
| +- javax.servlet:servlet-api:jar:2.5:compile
以及稍后实际引用的版本...
+- commons-collections:commons-collections:jar:3.1:compile
有没有办法让dependency:tree输出因冲突而省略的版本?
谢谢!
是的,您可以通过将 verbose
属性设置为 true
:
来获得省略的工件
Whether to include omitted nodes in the serialized dependency tree.
此属性默认为 false
。在命令行上,您将拥有
mvn dependency:tree -Dverbose=true
根据this,-Dverbose=true
参数在插件的 3.0 及更高版本中被忽略。您需要使用旧版本;上面的 link 建议如下(对我有用):
mvn org.apache.maven.plugins:maven-dependency-plugin:2.10:tree -Dverbose=true
我建议使用 depgraph-maven-plugin。
- 要查看所有依赖项,请将
showDuplicates
设置为 true
- 这将包括
dependency:tree
将使用 verbose
选项显示的依赖项
- 要查看冲突,请将
showConflicts
设置为 true
- 对 include/exclude 个项目有各种过滤器
- 可以导出为各种格式,包括可以用 GraphViz 渲染的点文件
- 我使用 vscode 插件 GraphViz Interactive Preview 渲染和查看点文件。
示例配置:
<plugin>
<groupId>com.github.ferstl</groupId>
<artifactId>depgraph-maven-plugin</artifactId>
<version>3.3.0</version>
<configuration>
<showDuplicates>true</showDuplicates>
<showConflicts>true</showConflicts>
<includes>
<!-- groupId:artifactId:type:classifier -->
<include>com.mycompany*:*</include>
</includes>
</configuration>
</plugin>
然后运行在你的项目mvn depgraph:graph
中找到一个新文件target/dependency-graph.dot
.
请注意,您可以包含范围为 provided
的插件,这样它就不会包含在任何构建工件中。
在 Eclipse 中,当我转到 Maven Dependency Hierarchy 页面时,我得到的输出说明是什么冲突导致版本被省略:
但是,如果我使用 dependency:tree,那将被忽略,我只看到实际使用的版本:
| +- commons-httpclient:commons-httpclient:jar:3.1:compile
| +- commons-codec:commons-codec:jar:1.4:compile
| +- commons-io:commons-io:jar:2.4:compile
| +- commons-net:commons-net:jar:3.1:compile
| +- javax.servlet:servlet-api:jar:2.5:compile
以及稍后实际引用的版本...
+- commons-collections:commons-collections:jar:3.1:compile
有没有办法让dependency:tree输出因冲突而省略的版本?
谢谢!
是的,您可以通过将 verbose
属性设置为 true
:
Whether to include omitted nodes in the serialized dependency tree.
此属性默认为 false
。在命令行上,您将拥有
mvn dependency:tree -Dverbose=true
根据this,-Dverbose=true
参数在插件的 3.0 及更高版本中被忽略。您需要使用旧版本;上面的 link 建议如下(对我有用):
mvn org.apache.maven.plugins:maven-dependency-plugin:2.10:tree -Dverbose=true
我建议使用 depgraph-maven-plugin。
- 要查看所有依赖项,请将
showDuplicates
设置为 true- 这将包括
dependency:tree
将使用verbose
选项显示的依赖项
- 这将包括
- 要查看冲突,请将
showConflicts
设置为 true - 对 include/exclude 个项目有各种过滤器
- 可以导出为各种格式,包括可以用 GraphViz 渲染的点文件
- 我使用 vscode 插件 GraphViz Interactive Preview 渲染和查看点文件。
示例配置:
<plugin>
<groupId>com.github.ferstl</groupId>
<artifactId>depgraph-maven-plugin</artifactId>
<version>3.3.0</version>
<configuration>
<showDuplicates>true</showDuplicates>
<showConflicts>true</showConflicts>
<includes>
<!-- groupId:artifactId:type:classifier -->
<include>com.mycompany*:*</include>
</includes>
</configuration>
</plugin>
然后运行在你的项目mvn depgraph:graph
中找到一个新文件target/dependency-graph.dot
.
请注意,您可以包含范围为 provided
的插件,这样它就不会包含在任何构建工件中。