应该放在哪里maven-compiler-plugin声明:in< plugins>或者< pluginManagement>? [英] Where should be placed maven-compiler-plugin declaration: in <plugins> or <pluginManagement>?

查看:122
本文介绍了应该放在哪里maven-compiler-plugin声明:in< plugins>或者< pluginManagement>?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个多模块maven项目,我想让我的所有子模块使用root pom中指定的 maven-compiler-plugin .XML 。我应该在哪里放置 maven-compiler-plugin 声明(在root pom.xml 中):in < plugins> 部分或< pluginManagement> 部分?问题也与 maven-release-plugin 有关。

I have a multi-module maven project, and I want to cause all my submodules to use maven-compiler-plugin specified in root pom.xml. Where I should place maven-compiler-plugin declaration (in root pom.xml): in <plugins> section or in <pluginManagement> section? Question also relates to maven-release-plugin too.

推荐答案

这些2个部分(插件 pluginManagement )的目的略有不同。

These 2 sections (plugins and pluginManagement) have slightly different purposes.

第一个( plugins )用于指定项目的构建过程(以及从父项目继承的所有子项目)。如果在本节中包含一些插件,它将在每个子项目中执行,而不管其类型如何。

The first one (plugins) is used to specify the build process of your project (and all of the child projects that inherit from the parent project). If you include some plugin into this section, it will be executed in each of the child projects regardless of its type.

第二个( pluginManagement )用于为从父项目继承的所有项目指定常见的插件设置(例如,插件版本和配置)。

The second one (pluginManagement) is used to specify common plugin settings for all of the projects that inherit from the parent project (for example, plugin version and configuration).

说到你提到的2个插件。 maven-compiler-plugin 是一个默认插件,无论你是否指定它都将被执行。将它包含在 pluginManagement 中并在那里指定其配置是有意义的。但是, maven-release-plugin 默认情况下不受任何生命周期阶段的约束。因此,如果您希望在所有子项目中执行它,则必须将其添加到插件部分。

Speaking of the 2 plugins that you've mentioned. maven-compiler-plugin is a default plugin that will be executed whether you specify it or not. It makes sense to include it in pluginManagement and specify its configuration there. maven-release-plugin, however, is not bound to any lifecycle phase by default. So if you'd like it to be executed in all of your child projects, you'll have to add it to plugins section.

这篇关于应该放在哪里maven-compiler-plugin声明:in&lt; plugins&gt;或者&lt; pluginManagement&gt;?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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