Build order of Maven multimodule project?

心不动则不痛 提交于 2019-11-28 05:40:45

The build order is determined by the Maven reactor which is a mechanism that automatically ensures correct build order for multimodule builds by sorting the projects.

See the official documentation for how it works.

It says:

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)

You can't manually control the build order. If you want to change the order you have to make changes to your project that influence the reactor sort order.

At a high level, the build order is based on a topological sort of the module dependency graph.

EDIT: Question for you. I understand that project 1 contains two modules and so does project 2. But do the modules in project 2 explicitly declare the "parent" pom as a parent? I'm thinking that perhaps your project 1 modules explicitly declare the parent pom, and the project 2 modules don't. Which would mean that the project 2 "parent" isn't really a parent at all and therefore doesn't have to be built before the modules. That's my guess anyway.

I've been living this issue lately with Centos 7. I updated maven to 3.5.3 from 3.0.5 and this problem has been solved. If anyone has this issue try that first.

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