问题
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