jjzjj

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

coder 2024-03-11 原文

我已将 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)
  • 我能否修复或避免它?
  • Maven 2 是否总是用于 -Dverbose 输出,但直到现在他们才添加了警告?

最佳答案

您的问题的解释可以在 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.

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

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,它实际上会打印警告。

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

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 功能时摆脱它。

关于java - "Using Maven 2 dependency tree to get verbose output, which may be inconsistent with actual Maven 3 resolution",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29409087/

有关java - "Using Maven 2 dependency tree to get verbose output, which may be inconsistent with actual Maven 3 resolution"的更多相关文章

随机推荐