带有一个插件模块的 maven 多模块项目 [英] maven multi-module project with one plugin module

查看:65
本文介绍了带有一个插件模块的 maven 多模块项目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在考虑在 maven 中创建一个多模块项目,带有一个插件模块(即这个模块在其他项目中用作插件,而不是依赖项).

问题:在多模块 Maven 项目中将插件作为模块是否可行?

解决方案

这是可行的,并且也在 官方 maven 多模块/反应器页面,关于构建如何将插件作为模块处理(粗体是我的):

<块引用>

因为多模块构建中的模块可以相互依赖,所以反应器以一种确保任何项目在需要之前构建的方式对所有项目进行排序是很重要的.

排序项目时遵循以下关系:

  • 项目依赖于构建中的另一个模块
  • 插件声明,其中插件是构建中的另一个模块
  • 插件依赖于构建中的另一个模块[..]

一旦安装并部署了插件,它就不会带来任何关于其模块性质的知识,也就是说,它将被将使用它的项目视为一个普通插件通过其独特的 maven 坐标 (GAV).
这同样适用于原型,原型可以是多模块项目的模块,然后单独使用.

另请注意,您可以拥有 - 例如 - 聚合器项目 项目(然后是模块)之间完全不相关,并且,比如说,只是聚合然后因为您想将它们全部构建在一起(通常没有意义,但在某些情况下很有用).>

I am thinking about creating a multi-module project in maven, with one plugin module (i.e. this module is used as a plugin in other projects, not a dependency).

Question: Is it feasible to have a plugin as a module in a multi module maven project?

解决方案

It is feasible and it is also documented on the official maven multi-module/reactor page concerning how having a plugin as module is handled by the build (bold is mine):

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 [..]

Once the plugin is installed and deployed, it will then not bring with it any knowledge of its module nature, that is, it will be seen as a normal plugin by the projects that will use it via its unique maven coordinates (GAV).
The same is applied to archetypes, which can be modules of a multi module project and then be used individually.

Also note that you can have - as an example - an aggregator project of projects (then modules) completely unrelated between each other, and, say, just aggregate then because you want to build them all together (often not really meaningful, but useful in some cases).

这篇关于带有一个插件模块的 maven 多模块项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆