“隐式"插件 - 为什么即使在 POM 中没有提到 Maven 构建也通过surefire运行测试? [英] "Implicit" plugins - why does a Maven build run tests via surefire even if it is not mentioned in the POM?
问题描述
通常,要在构建过程中使用 Maven 插件,需要通过将其放入 POM 的
部分来显式激活它.
Normally, to use a Maven plugins during the build, it needs to be explicitly activated by putting it into the <build>
section of the POM.
但是,如果您制作了一个最小的 POM(构建"部分中没有插件)并运行 Maven 构建,Maven 将默认运行一些插件,例如通过 surefire 编译和运行测试.
However, if you make a minimal POM (no plugins in the "build" section) and run a Maven build, Maven will run some plugins by default, such as compiling and running tests via surefire.
这是如何工作的?是否有一些默认"插件的内部列表?或者这是在超级POM"中定义的?我尝试查找超级 POM,但给出的示例(在Maven:完整参考"中)没有列出 surefire 插件.
How does this work? Is there some internal list of "default" plugins? Or is this defined in the "super POM"? I tried looking up a super POM, but the example given (in "Maven: The Complete Reference") does not list the surefire plugin.
推荐答案
在构建期间将被激活的插件列表(如果没有其他明确声明)取决于项目打包.例如,对于 jar
和 war
项目,默认生命周期包含 test
阶段,它被绑定到 surefire:test
默认.请参阅此处了解更多信息.
The list of plugins that are going to be activated during the build (if no other are explicitly declared) depends on project packaging. For example, for jar
and war
projects, default lifecycle contains test
phase which is bind to surefire:test
by default. See here for more info.
这篇关于“隐式"插件 - 为什么即使在 POM 中没有提到 Maven 构建也通过surefire运行测试?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!