Maven - 添加自定义阶段以使用其他配置执行插件
我在一个 Maven 项目中有两组集成测试 - 自动测试和手动测试。手动测试很少但很乏味 - 它们需要拔掉服务器的插头等。我想为手动测试创建一个单独的目标,这样我就可以运行诸如 mvn manualtests
之类的东西来运行手动测试。如果您只是运行普通的 Maven 构建 mvn install
左右,则应该运行自动测试。
我已经使用 TestNG 注释 @Test(groups="manual"
) 对手动测试进行了注释。现在的目标是获得 Surefire 插件的两种配置,一种运行自动测试,该测试绑定到构建的测试阶段,以及运行手动测试的阶段,该阶段绑定到另一个自定义阶段,我想将其称为manualtests
似乎不可能绑定插件的执行。到一个不存在的阶段(即不是由maven预定义的阶段)。是否无法定义自己的阶段?
I have two set of integration tests in one maven project - automatic and manual tests. The manual tests are few but tedious - they require pulling the plug of servers etc. I would like to create a separate goal for the manual tests, so i can run something like mvn manualtests
to run the manual tests. If you just run a normal maven build mvn install
or so, the automatic tests should be run.
I've already annotated the manual tests with the TestNG annotation @Test(groups="manual"
. The goal is now to have two configurations of the surefire plugin, one running the automatic tests which is bound to the test phase of the build, and one running the manual tests which is bound to another custom phase that I would like to call manualtests
. It seems as if it is not possible to bind an execution of a plugin to a nonexistent phase (i.e one which isn't predefined by maven). Is it not possible to define your own phases?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这应该是可能的,尽管并不容易。第一步:看看默认情况下它是如何完成的。
使用此依赖项:
获取源代码并查看 META-INF/plexus 内的 Components.xml。在那里,定义了默认阶段和默认生命周期/阶段绑定。
创建一个覆盖这些默认阶段的插件(在它自己的 Components.xml 中)和 将其定义为扩展
That should be possible, though not easy. First step: look at how it's done by default.
use this dependency:
get the sources and have a look at the components.xml inside META-INF/plexus. there, both the default phases and the default lifecycle / phase bindings are defined.
create a plugin that overrides these default phases (in it's own components.xml) and define it as an extension
您也许可以使用配置文件来实现:
http://maven.apache.org/guides/introduction/introduction- to-profiles.html
You might be able to use profiles for that:
http://maven.apache.org/guides/introduction/introduction-to-profiles.html