java - Maven 构建顺序(多个模块)

我有一个 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/

相关文章:

haskell - 由于 native 依赖项中的 "multiple definition"链接器

build - Intellij IDEA 项目中的自定义构建步骤

java - 从相同的源代码构建可以产生功能不同的可执行文件吗?

c# - Visual Studio 2010 构建错误 - 来自 HRESULT : 0x8003

c# - C# 中的友元程序集

.net - IoC 容器,在编译时检查错误

maven - 是否有从 Maven 到 Bazel 的迁移路径?

perl - 有没有最简单的方法来构建 perl 包

build - Xamarin:使用 NDK 构建的 .so

c++ - C++ 项目的 cmake vs waf