Maven3.x兼容笔记

一、依赖解析

The core of Maven 3 uses Aether for dependency resolution. Aether employs a different approach to calculate the transitive dependencies and is meant to fix some of the trickier (conflict) resolution issues within Maven 2.x.

In practice, this change can result in different class paths especially for projects with big/complex dependency graphs. For instance, projects that erroneously have conflicting dependencies on their classpath might encounter build issues depending on the classpath order. See JETTY-1257 for a concrete example of this issue.

Furthermore, not all parts of the Maven 2.x resolution API could be bridged onto Aether. Most notably the maven-dependency-tree shared component which is used for mvn dependency:tree still uses the legacy resolution code. As such, the output from mvn dependency:tree can differ from the actual dependency tree used by Maven itself to derive the classpaths of a project (see MSHARED-167 for an example of such a discrepancy). For now, the actual dependency trees can be inspected when running Maven with debug logging enabled.

Last but not least, Maven 3 inspects the POMs of all matching versions when processing version ranges to enable sophisticated conflict resolution.

Maven3.x的core使用Aether进行依赖解析,其于Maven2.x表现不一致。也就是说使用maven2和maven3对一个项目构建时结果可能不一致。

有些插件仍在使用老的解析API,如mvn dependency:tree使用的maven-depdency-tree共享组件。这就导致通过mvn dependency:tree的结果与Maven core计算的依赖树不同。

二、插件仓库

Maven 3 aims at supporting a stricter separation between the compile/runtime/test dependencies of a project and the plugins used to build the project. For this reason, build extensions, plugins and plugin dependencies are no longer resolved from the of a project but only from its.

Maven3开始插件的依赖只会从plugin仓库获取,目的是为了隔离插件和项目构件,简化运维工作。

#、参考

  1. https://cwiki.apache.org/confluence/display/MAVEN/Maven+3.x+Compatibility+Notes

评论