"Using Maven 2 dependency tree to get verbose output, which may be inconsistent with actual Maven 3 resolution"

"Using Maven 2 dependency tree to get verbose output, which may be inconsistent with actual Maven 3 resolution"

我已将 maven-dependency-plugin 的旧版本从 2.8 更改为 2.10。现在,当我 运行 mvn dependency:tree -Dverbose 我看到以下警告:

[WARNING] Using Maven 2 dependency tree to get verbose output, which may be inconsistent with actual Maven 3 resolution

我使用的Maven版本是

Apache Maven 3.2.1 (ea8b2b07643dbb1b84b6d16e1f08391b666bc1e9; 2014-02-14T18:37:52+01:00)

您的问题的解释可以在 official documentation:

找到

verbose Whether to include omitted nodes in the serialized dependency tree. Notice this feature actually uses Maven 2 algorithm and may give wrong results when used with Maven 3.

查看 2.10 版 TreeMojo.java 的第 245 行:

if ( verbose )
{
    // verbose mode force Maven 2 dependency tree component use
    if ( ! isMaven2x() )
    {
        getLog().warn( "Using Maven 2 dependency tree to get verbose output, "
                           + "which may be inconsistent with actual Maven 3 resolution" );
    }
    dependencyTreeString =
        serializeVerboseDependencyTree( dependencyTreeBuilder.buildDependencyTree( project,
                                                                                   localRepository,
                                                                                   artifactFilter ) );
}

如果不使用 maven 2,它实际上会打印警告。

现在查看 2.8 版 TreeMojo.java 的第 243 行:

if ( verbose )
{
    // verbose mode force Maven 2 dependency tree component use
    dependencyTreeString =
        serializeVerboseDependencyTree( dependencyTreeBuilder.buildDependencyTree( project,
                                                                                   localRepository,
                                                                                   artifactFilter ) );
}

那里不存在警告日志记录,因此:

Was it always the case that Maven 2 was used for -Dverbose output but only now they have added the warning?

是的,从 2.8 版本开始添加了警告。

Can I fix it or avoid it anyhow?

我猜不是,也就是说没有忽略警告日志消息或编辑源代码。

但是,如您所见,Maven 2 功能已在 2.8 中使用。希望当他们迁移 dependency:tree -Dverbose 以使用 maven 3 功能时,您会在以后的版本中摆脱它。