我有一个 Maven 父项目,它有多个子/模块...我有以下 pom.xml 作为主/父项目;
<modules>
<module>Main-Ear</module>
<module>Sub-Web</module>
<module>Sub-Ui</module>
<module>Sub-Services</module>
<module>Sub-SSO-Login</module>
</modules>
但是,我发现实际的构建顺序有所不同... 构建后,实际顺序如下:
Main
Sub-Services
Sub-SSO-Login
Sub-UI
Sub-Web
Main-Ear
在这种情况下,Maven 究竟从哪里获取构建顺序?
最佳答案
您无法手动控制构建顺序:
来自 Maven 项目文档 (Guide to Working with Multiple Modules):
Reactor Sorting
Because modules within a multi-module build can depend on each other, it is important that The reactor sorts all the projects in a way that guarantees any project is built before it is required.
The following relationships are honoured when sorting projects:
- a project dependency on another module in the build
- a plugin declaration where the plugin is another modules in the build
- a plugin dependency on another module in the build
- a build extension declaration on another module in the build the order declared in the element (if no other rule applies)
Note that only "instantiated" references are used - dependencyManagement and pluginManagement elements will not cause a change to the reactor sort order
https://stackoverflow.com/questions/18629897/