如何让 maven-release-plugin 跳过我的测试?
如何在不触发测试的情况下运行 maven-release-plugin?
我已经尝试
-Dmaven.test.skip=true
过
-DskipTests
......
-DpreparationGoals=clean
但没有任何效果。
是的,我知道如果测试未通过,我不应该发布,但我无法控制让我的同事编写可靠的测试。
How can I get the maven-release-plugin to run without triggering the tests?
I have tried
-Dmaven.test.skip=true
and
-DskipTests
and
-DpreparationGoals=clean
...yet none work.
Yes, I know I shouldn't release if the tests don't pass, but I don't have control over making my coworkers write reliable tests.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(7)
-Darguments="-DskipTests"
是您想要的,或者在 pom.xml 中显式配置分叉执行。-Darguments="-DskipTests"
is what you want, or explicitly configuring the forked executions in the pom.-Darguments="..."
将参数传递给分叉的 Maven 进程,但重要的是要意识到这里使用了两个不同的开关。-DskipTests
强制 maven 不运行任何测试,但测试仍会编译(如果您对测试 jar 类型有任何依赖项,这一点很重要)。 -Dmaven.test.skip=true 强制 maven 甚至不编译测试,这意味着不会生成任何测试 jar。因此,您必须使用
-Darguments
,但要跳过正在运行的测试,请仅使用skipTests
,要停止编译,请使用maven.test.skip
。-Darguments="..."
passes arguments to the forked maven process, but it is important to realise that there are two different switches being used here. The-DskipTests
forces maven to not run any tests, but the tests are still compiled (this is important if you have any dependencies on a test-jar type). The-Dmaven.test.skip=true
forces maven to not even compile the tests, which means that any test-jars will not be generated.So, you must use
-Darguments
, but to skip tests running use onlyskipTests
, to stop them compiling usemaven.test.skip
.如果您只想跳过集成测试,可以这样做:
If you just want to skip integration tests, this will do it:
您有太多不同的选择来避免和跳过发布插件的测试
例如:
mvn -X -Darguments="-Dmaven. javadoc.skip=true -Dmaven.test.skipTests=true -Dmaven.test.skip=true" -P release-mode release:prepare
-第二个是执行这些构建中 pom.xml 上的参数如下所示:
请注意,第二个方法会覆盖第一个方法。
我建议您首先在单个操作上准备发布,然后您可以编辑工作目录中的release.properties 文件,并查看
exec.additionalArguments
属性(如果您的参数存在)。它看起来像:exec.additionalArguments=-Dmaven.javadoc.skip\=true -Dmaven.test.skipTests\=true -Dmaven.test.skip\=true -P release-mode
。之后就可以执行释放了。
you have too differents choices to avoid and skip tests with the release plugin
exemple:
mvn -X -Darguments="-Dmaven.javadoc.skip=true -Dmaven.test.skipTests=true -Dmaven.test.skip=true" -P release-mode release:prepare
-The second is to perform thoses arguments on your pom.xml in the build like this:
Note that the second method override the first.
I recommanded you to prepare release first on a single action and then you can edit the release.properties file on the working directorie and look the
exec.additionalArguments
properties if your arguments are there. It will look like:exec.additionalArguments=-Dmaven.javadoc.skip\=true -Dmaven.test.skipTests\=true -Dmaven.test.skip\=true -P release-mode
.After you can perform the release.
我通过简单地将
configuration
preparationGoals
添加到clean
来避免运行verify
目标:I have managed to avoid running the
verify
goal by simply adding theconfiguration
preparationGoals
toclean
:使用以下参数跳过测试
或
默认跳过
Use the following argument to skip test
or
alternatively skipping by default
当您使用 gitflow-maven-plugin 跳过测试时,请在配置属性中使用 skipTestProject : true (默认值为 false)。文档中详细描述: https://aleksandr- m.github.io/gitflow-maven-plugin/release-finish-mojo.html
示例:
When You use gitflow-maven-plugin to skip tests use skipTestProject : true inside configuration property (default value is false). Described in details in documentation : https://aleksandr-m.github.io/gitflow-maven-plugin/release-finish-mojo.html
example :