没有插件目标绑定到 Maven 阶段 [英] No plugin goals bound to a maven phase

查看:77
本文介绍了没有插件目标绑定到 Maven 阶段的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在 maven 中相当新.通过阅读官方网站的maven文档,我知道默认的生命周期有21个阶段,包括validateinitializegenerate-sourcesprocess-sourcesgenerate-resourcesprocess-resourcescompileprocess-classesgenerate-test-sourcesprocess-test-sourcesgenerate-test-resourcesprocess-test-resourcestest-compile, test, prepare-package, package, pre-integration-test, 集成测试post-integration-testverifyinstalldeploy.

但是当我看到 内置生命周期绑定,我发现没有插件目标绑定到validateinitializeverify 等阶段
因此,如果我运行命令 mvn package,是否会执行没有插件目标的阶段?
或者这些阶段的插件目标是固定的,我们无法控制它们,因此无需将它们写入文档.每次validateinitializeverify等阶段都会自动执行.

解决方案

首先,没有插件绑定到 validateinitializeverify 默认情况下(以及其他一些阶段).

如果你运行 mvn package 所有阶段都将被执行,但如果没有插件绑定到一个阶段,你就看不到它.如果您运行 package 阶段,包括 package 阶段本身在内的所有阶段将从 validateinitialize 开始执行,generate-sources 等等...

有时将插件绑定到像 initialize 这样的阶段很有用.例如 build-number-maven-plugin.

verify 之前的阶段,例如 pre-integration-testintegration-testpost-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-sourcesand 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屋!

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