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

女生的网名这么多〃 提交于 2019-12-10 12:57:56

问题


I have changed used version of maven-dependency-plugin from 2.8 to 2.10. Now, when I run mvn dependency:tree -Dverbose I see the following warning:

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

The version of Maven I am using is

Apache Maven 3.2.1 (ea8b2b07643dbb1b84b6d16e1f08391b666bc1e9; 2014-02-14T18:37:52+01:00)
  • Can I fix it or avoid it anyhow?
  • Was it always the case that Maven 2 was used for -Dverbose output but only now they have added the warning?

回答1:


The explanation to your problem can be found at the 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.

Have a look at line 245 of TreeMojo.java for version 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 ) );
}

It actually prints the warning if maven 2 is not used.

Now look at line 243 of TreeMojo.java for version 2.8:

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

The warning logging does not exist there, so:

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

Yes, the warning has been added since version 2.8.

Can I fix it or avoid it anyhow?

I guess not, that is without ignoring warning log messages, or editing the source code.

However, as you can see, Maven 2 functionality was already used in 2.8. Hopefully you will get rid of it in later versions when they migrate dependency:tree -Dverbose to use maven 3 functionality.



来源:https://stackoverflow.com/questions/29409087/using-maven-2-dependency-tree-to-get-verbose-output-which-may-be-inconsistent

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!