maven依赖插件未显示测试范围的依赖项



我正试图从命令行使用maven依赖插件版本3.1.2显示我正在处理的项目的完整依赖关系树,但mvn dependency:tree目标(以及maven依赖性插件的任何其他目标(没有显示test依赖关系。插件的文档(https://maven.apache.org/plugins/maven-dependency-plugin/tree-mojo.html)声明默认情况下包括所有作用域,因此不需要使用-Dscope=test(但添加此参数时,输出不会更改(。

我已经用一个干净的.m2存储库运行了这个,不使用settings.xml文件(以确保所有工件都直接来自repo.maven.apache.org(。

我使用maven 3.6.2在linux环境中运行(CentOS 7(,并使用Oracle Java 1.8.0_144

这是我的POM:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.sw-eval</groupId>
<artifactId>cayenne-eval</artifactId>
<version>1.0.0-SNAPSHOT</version>
<dependencies>
<dependency>
<groupId>org.apache.cayenne</groupId>
<artifactId>cayenne-server</artifactId>
<version>4.2.M2</version>
</dependency>
<dependency>
<groupId>org.apache.cayenne</groupId>
<artifactId>cayenne-di</artifactId>
<version>4.2.M2</version>
</dependency>
<dependency>
<groupId>org.apache.cayenne</groupId>
<artifactId>cayenne-dbsync</artifactId>
<version>4.2.M2</version>
</dependency>
<dependency>
<groupId>org.apache.cayenne</groupId>
<artifactId>cayenne-client</artifactId>
<version>4.2.M2</version>
</dependency>
</dependencies>
</project>

以下是运行命令mvn dependency:tree:时收到的输出

[INFO] Scanning for projects...
[INFO] 
[INFO] ----------------------< com.sw-eval:cayenne-eval >----------------------
[INFO] Building cayenne-eval 1.0.0-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO] 
[INFO] --- maven-dependency-plugin:2.8:tree (default-cli) @ cayenne-eval ---
[INFO] com.sw-eval:cayenne-eval:jar:1.0.0-SNAPSHOT
[INFO] +- org.apache.cayenne:cayenne-server:jar:4.2.M2:compile
[INFO] |  - org.slf4j:slf4j-api:jar:1.7.25:compile
[INFO] +- org.apache.cayenne:cayenne-di:jar:4.2.M2:compile
[INFO] +- org.apache.cayenne:cayenne-dbsync:jar:4.2.M2:compile
[INFO] |  +- org.apache.cayenne:cayenne-project:jar:4.2.M2:compile
[INFO] |  - net.java.dev.inflector:inflector:jar:0.7.0:compile
[INFO] - org.apache.cayenne:cayenne-client:jar:4.2.M2:compile
[INFO]    +- com.caucho:hessian:jar:4.0.63:compile
[INFO]    - org.apache.cayenne:cayenne-rop-server:jar:4.2.M2:compile
[INFO]       +- org.apache.cayenne:cayenne-web:jar:4.2.M2:compile
[INFO]       - org.slf4j:slf4j-simple:jar:1.7.25:compile
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  2.951 s
[INFO] Finished at: 2020-11-25T08:53:17-07:00
[INFO] ------------------------------------------------------------------------

然而,当引用cayenne-serverpom时,有许多标记为test的依赖项没有显示在输出中(具体而言,以下是cayenne-server的直接依赖项,请参阅https://search.maven.org/artifact/org.apache.cayenne/cayenne-server/4.2.M2/jar):

<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.cayenne.build-tools</groupId>
<artifactId>cayenne-test-utilities</artifactId>
<version>${project.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-mock</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.mockrunner</groupId>
<artifactId>mockrunner-jdbc</artifactId>
<scope>test</scope>
<exclusions>
<exclusion>
<!-- this one have old Xerces dependency that clashes with JDK's one -->
<groupId>nekohtml</groupId>
<artifactId>nekohtml</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>xmlunit</groupId>
<artifactId>xmlunit</artifactId>
<scope>test</scope>
</dependency>

那么,是否有我缺少的东西需要启用以显示这些test范围的依赖项,和/或这是cayenne-server依赖项特有的奇怪工件?

提前感谢!

作用域test的依赖项不可传递。

依赖项的test依赖项不是依赖项树的一部分。它们被Maven忽略了。

最新更新