Maven的合并站点/部署目标 [英] Combined site/deploy goal for Maven

查看:83
本文介绍了Maven的合并站点/部署目标的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在CI服务器上运行Maven构建时,我将生成用于发布文档和报告的站点,还将工件部署到快照存储库以供其他项目使用.为此,我实现了以下目标:

When running a Maven build on the CI server, I generate the site to publish the documentation and reports, and also deploy the artifact to the snapshot repository for use by other projects. To do this I run the following goals:

mvn clean site deploy

这意味着单元测试将两次运行,一次用于站点生命周期,一次用于部署生命周期.如果我将网站目标配置为与标准生命周期绑定,则测试仍将运行两次,由于 @requiresDependencyResolution test 批注,运行网站目标将始终导致测试运行.如果您仅创建站点,这很好,但是在部署的情况下,它会极大地增加构建时间,而无济于事.

This means the unit tests are run twice, once for the site lifecycle and once for the deploy lifecycle. If I configure the site goal to be bound to the standard lifecycle the tests are still run twice, running the site goal always causes the tests to be run because of the @requiresDependencyResolution test annotation. This is fine if you're only creating the site, but in the context of a deploy it greatly increases the build time for no benefit.

我有一个解决方法,涉及将SiteMojo(和所需的父级)复制到新插件,并从副本中删除 @requiresDependencyResolution测试批注.

I have a workaround that involves copying the SiteMojo (and the required parents) to a new plugin and removing the @requiresDependencyResolution test annotation from the copy.

此经过修改的mojo将生成报告,而不会强制再次运行测试,但是我更喜欢不涉及任何网站插件黑客攻击的解决方案.有没有一种方法可以消除requireDependencyResolution批注?

This modified mojo will generate the reports without forcing the tests to be run again but I'd prefer a solution that doesn't involve any hacking of the site plugin. Is there a way to suppress the requiresDependencyResolution annotation?

推荐答案

我对此功能感到惊讶-@requiresDependencyResolution test标记实际上并未触发正在构建的测试-这应该是您已提交的报告之一包括.通常,我建议在CI中以独立的Maven执行方式运行站点和构建,以便您可以快速获取构建反馈并仅在成功后发布最新站点.

I'm surprised this works - the @requiresDependencyResolution test tag doesn't actually trigger the tests being built - that should be one of the reports that you've included. Normally, I recommend running the site and the build in separate Maven executions in CI so you can get fast feedback on your build and publish the latest site only when that succeeds.

另一种替代方法是将其作为mvn clean deploy site运行,并为surefire-report-maven-plugin选择report-only mojo(通常是再次运行测试的报告).这将使用以前的测试结果.当然,另一种选择是完全禁用该报告,因为无论如何您都可能会从其他来源(例如CI服务器)获得这些结果.

Another alternative is to run it as mvn clean deploy site, and choose the report-only mojo for surefire-report-maven-plugin (this is usually the report that is running the tests again). This will use the previous test results. Of course, another alternative is disabling that report altogether, since you likely get those results from another source such as your CI server anyway.

这篇关于Maven的合并站点/部署目标的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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