没有插件目标绑定到 Maven 阶段 [英] No plugin goals bound to a maven phase
问题描述
在 maven 中相当新.通过阅读官方网站的maven文档,我知道默认的生命周期有21个阶段,包括validate
、initialize
、generate-sources
、process-sources
,generate-resources
、process-resources
、compile
、process-classes
、generate-test-sources
、process-test-sources
、generate-test-resources
、process-test-resources
、test-compile
, test
, prepare-package
, package
, pre-integration-test
, 集成测试
、post-integration-test
、verify
、install
和deploy
.>
但是当我看到 内置生命周期绑定,我发现没有插件目标绑定到validate
、initialize
、verify
等阶段
因此,如果我运行命令 mvn package
,是否会执行没有插件目标的阶段?
或者这些阶段的插件目标是固定的,我们无法控制它们,因此无需将它们写入文档.每次validate
、initialize
、verify
等阶段都会自动执行.
首先,没有插件绑定到 validate
、initialize
和 verify
默认情况下(以及其他一些阶段).
如果你运行 mvn package
所有阶段都将被执行,但如果没有插件绑定到一个阶段,你就看不到它.如果您运行 package
阶段,包括 package
阶段本身在内的所有阶段将从 validate
、initialize
开始执行,generate-sources
等等...
有时将插件绑定到像 initialize
这样的阶段很有用.例如 build-number-maven-plugin一>.
verify
之前的阶段,例如 pre-integration-test
、integration-test
和 post-integration-test
可用于运行可由 maven-failsafe-plugin 处理的集成测试.单元测试由 maven-surefire-plugin 处理.
像 generate-sources
这样的阶段经常被像 jaxb2-maven-plugin 或其他类似注解处理器生成插件...
Quite new in maven. By reading document of maven at official website, I know in the default lifeCycle, there are 21 phases including validate
, initialize
, generate-sources
, process-sources
, generate-resources
, process-resources
, compile
, process-classes
, generate-test-sources
, process-test-sources
, generate-test-resources
, process-test-resources
, test-compile
, test
, prepare-package
, package
, pre-integration-test
, integration-test
, post-integration-test
, verify
, install
and deploy
.
But when I see Built-in Lifecycle Bindings, I found that there is no plugin goals binding to phases like validate
, initialize
, verify
, etc.
So if I run command mvn package
, are phases without plugin goals going to be executed?
Or plugins goals for these phases are fixed and we do not have control of them so there is no need to write them in the document. Every time these phases like validate
, initialize
, verify
, etc. will be executed automatically.
First yes there are no plugins bound to the phases validate
, initialize
and verify
by default (and some other phases as well).
If you run mvn package
all phases will be executed but if there is no plugin bound to a phase you can't see it. If you run package
phase all the phases including package
phase itself will be executed from the beginning validate
, initialize
, generate-sources
and so on...
Sometimes it is useful to bind plugins to phases like initialize
. This is the case for example for the build-number-maven-plugin.
Phases before verify
like pre-integration-test
, integration-test
and post-integration-test
are useful to run integration tests which can be handled by maven-failsafe-plugin. The unit tests are handled by the maven-surefire-plugin.
Phases like generate-sources
are often used by source generating plugins like jaxb2-maven-plugin or others like annotation processor generation plugins...
这篇关于没有插件目标绑定到 Maven 阶段的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!