如何从 mvn dependency:tree 中排除所有测试 jar*

How exclude all test jars* from mvn dependency:tree

有什么方法可以排除测试目标中使用的依赖项吗? 例如,我想避免 mvn dependency:tree.

打印所有 *:tests jar
[INFO] Building test 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO] 
[INFO] --- maven-dependency-plugin:2.8:tree (default-cli) @ test ---
[INFO] com.test.test:jar:1.0-SNAPSHOT
[INFO] +- junit:junit:jar:4.13:test
[INFO] |  \- org.hamcrest:hamcrest-core:jar:1.3:test
[INFO] +- org.specs2:specs2-core_2.13:jar:4.8.3:test
[INFO] |  +- org.specs2:specs2-matcher_2.13:jar:4.8.3:test
[INFO] |  +- org.specs2:specs2-common_2.13:jar:4.8.3:test
[INFO] |  |  +- org.specs2:specs2-fp_2.13:jar:4.8.3:test
[INFO] |  |  \- org.scala-lang.modules:scala-parser-combinators_2.13:jar:1.1.2:compile
[INFO] |  \- org.scala-sbt:test-interface:jar:1.0:test
[INFO] +- org.scalatest:scalatest_2.13:jar:3.1.0:test
[INFO] |  +- org.scalactic:scalactic_2.13:jar:3.1.0:test
[INFO] |  +- org.scala-lang:scala-reflect:jar:2.13.1:test
[INFO] \- com.fasterxml.jackson.core:jackson-databind:jar:2.10.2:compile

许多 jar 在编译阶段使用,而其他在测试阶段使用。 我正在寻找:

mvn dependency:tree -Dexcludes=org.apache.maven*

所以我想知道是否可以通过命令行直接排除所有*tests

您可以这样添加 scope

mvn dependency:tree -Dscope=compile