我想获取我的 Maven 项目的所有依赖项的列表,但没有使用 Maven 3.6.2 的测试依赖项。
列出我成功使用dependency:tree
或dependency:list
的所有依赖项。
然后我尝试添加 -DincludeScope=compile
和 -DexcludeScope=test
作为参数。添加这些后,我仍然可以获得测试依赖项。
命令示例
mvn -f example/location/pom.xml dependency:tree -DincludeScope=compile -DexcludeScope=test
输出
...
...
...
\- junit:junit:jar:4.12:test
\- org.hamcrest:hamcrest-core:jar:1.3:test
父依赖项进行测试,子项依赖项进行编译
我还发现了另一个问题。如果父依赖项是 test
那么我不想看到它的任何依赖项。
...
...
| +- com.google.cloud:google-cloud-core-grpc:jar:1.52.0:test
| | +- com.google.auth:google-auth-library-credentials:jar:0.11.0:compile
如何删除所有测试依赖项及其子项?
最佳答案
includeScope
和 excludeScope
不是 dependency:tree
Mojo 的参数所以它们不会有任何影响。根据您的 maven-plugin-dependency
版本,scope
参数可能有效(请参阅 MSHARED-4 ):
mvn dependency:tree -Dscope=compile
关于java - 获取不包括测试依赖项的 Maven 依赖项列表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59155978/