Maven - 添加自定义阶段以使用其他配置执行插件

发布于 2024-09-07 00:57:58 字数 427 浏览 0 评论 0原文

我在一个 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

甜是你 2024-09-14 00:57:58

这应该是可能的,尽管并不容易。第一步:看看默认情况下它是如何完成的。

使用此依赖项:

<dependency>
    <groupId>org.apache.maven</groupId>
    <artifactId>maven-core</artifactId>
    <version>${maven.version}</version>
</dependency>

获取源代码并查看 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:

<dependency>
    <groupId>org.apache.maven</groupId>
    <artifactId>maven-core</artifactId>
    <version>${maven.version}</version>
</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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文