What is the "reactor" in Maven?

I've been reading about Maven reactor and am confused by its terminology usage. I've read that a multi-module is a reactor, that you can manipulate the maven reactor and that the reactor is a plugin. What exactly is the reactor?

47176 次浏览

反应器是 Maven 的一部分,它允许 Maven 在一组模块上执行一个目标。正如在 Maven 1.x 关于多模块构建的文档中提到的(反应堆的概念已经在 Maven 1.x 中提到了) ,而模块是 离散的工作单位,他们可以聚集在一起使用反应堆建立他们同时和:

反应器根据每个项目在其各自的项目描述符中陈述的依赖项确定正确的构建顺序,然后执行一组陈述的目标。它既可以用于构建项目,也可以用于其他目标,例如站点生成。

正如解释的那样,反应器使多模块构建成为可能: 它计算模块之间的依赖关系的有向图,从这个图中导出构建顺序(这就是为什么不允许循环依赖关系,这无论如何是件好事) ,然后对模块执行目标。换句话说,“ 多模块构建”是“ 建造反应堆”,“ 建造反应堆”是“ 多模块构建”。

In Maven 2.x, the support of multi-module builds has been very much improved and the reactor has become transparent to Maven users. But it's still there and is used under the hood.

In September 2008 (i.e. a long time after the rollout of Maven 2), a 反应堆插件 has been created to make it possible to interact (again) more closely with the Maven reactor. Brett Porter blogged about it in 反应堆: 我最喜欢的新专家插件.

现在大多数反应器插件特性都得到了本机支持(自 Maven2.1.0以来)。

当一个项目有多个模块时使用反应堆。

The work done by reactor is:

  • 收集模块详细信息
  • 根据依赖项对顺序进行排序
  • 按顺序构建项目

从2.1版本开始,有了新的命令行选项,允许您操作 Maven 构建多模块项目的方式。这些新的选择是:

-rf, --resume-from
Resume reactor from specified project
-pl, --projects
Build specified reactor projects instead of all projects
-am, --also-make
If project list is specified, also build projects required by the list
-amd, --also-make-dependents
If project list is specified, also build projects that depend on projects on the list

更多细节: