Maven Cobertura 插件未生成coverage.xml
我试图生成一个coverage.xml,以便我可以在Hudson 的Cobertura 插件中引用它,但该文件没有被创建。
我已将以下内容添加到我的 POM
<reporting>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>cobertura-maven-plugin</artifactId>
<version>2.5.1</version>
<configuration>
<formats>
<format>html</format>
<format>xml</format>
</formats>
</configuration>
</plugin>
</plugins>
</reporting>
运行 mvn cobertura:cobertura 后,将按预期在 **\target\site\cobertura 生成 HTML 站点,但无法找到coverage.xml。我错过/误解了什么?
我正在运行 Maven 3.0.3
I am trying to generate a coverage.xml so that I can reference it in Cobertura plugin of Hudson, but the file is not being created.
I've added the following to my POM
<reporting>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>cobertura-maven-plugin</artifactId>
<version>2.5.1</version>
<configuration>
<formats>
<format>html</format>
<format>xml</format>
</formats>
</configuration>
</plugin>
</plugins>
</reporting>
After running mvn cobertura:cobertura, the HTML site is generated as expected at **\target\site\cobertura, but coverage.xml is nowhere to be found. What am I missing/misunderstanding?
I am running Maven 3.0.3
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(8)
将以下行添加到您的应用程序目标:(在 jenkins 中配置应用程序的部分)
pom.xml 更改:
Add below lines to your application Goals:(configure section of the application in jenkins)
pom.xml changes:
我将插件放在构建部分并且它可以工作:
报告部分及其与插件部分的差异被描述这里。我不知道这是 Maven [3.0.4] 还是 cobertura-plugin 问题。
I put the plugin in the build section and it works:
The reporting section and its differences to the plugin section are described here. I don't know if this is a maven [3.0.4] or cobertura-plugin issue.
对于 Maven 插件和 Hudson 及其插件之间的连接,我仍然是一个新手 - 所以这无论如何都不是一个明智的答案,但 Google 上的帮助对于这个问题非常少 - 所以希望它能帮助某人将来。
在花了几个小时修改设置后,我发现coverage.xml似乎根本不是在本地构建的。
这是使它工作的组合:
在 2.5.1 中未发现 Apache 的错误)
推荐 **/target/site/cobertura/coverage.xml
I'm still quite a novice with the connections between Maven Plugins and Hudson and it's plugins - so this isn't an intelligent answer by any means, but help on Google is very few and far between for this issue - so hopefully it helps someone in the future.
After spending a few more hours of tinkering with settings, I've found that the coverage.xml simply doesn't seem to be built locally.
This is the combination that got it working:
not found errors from Apache with 2.5.1)
recommended **/target/site/cobertura/coverage.xml
我的目标是让 Cobertura 在
mvn test
期间运行,无需额外的命令行参数。这是神奇的 XML,它为我提供了帮助,HTML 和 XML 都是在/target/site/cobertura
中生成的。My objective was to get Cobertura to run duing
mvn test
with no additional command line parameters. Here's the magic XML that did the trick for me, with both the HTML and XML being generated in/target/site/cobertura
.我遇到了同样的问题,但现在已经解决了:
只需在 Maven 命令后添加
-Dcobertura.report.format=xml
即可。应该有效I had the same issue but it's resolved right now:
Just add
-Dcobertura.report.format=xml
after your maven command. It should work我在使用 2.6 插件时遇到了同样的问题。
我发现当我指定这两种类型时,我只得到html。
但是当我仅指定 xml 时,我会得到一份 xml 报告。
这可能是插件中的一个错误。
另一位用户建议创建两个执行。我尝试过但没有成功(这意味着我得到了 html,但没有得到 xml)。
I have the same issue using 2.6 of the plugin.
I found that when I specify both types, I only got html.
But when I specify only xml, I get an xml report.
This is probably a bug in the plugin.
Another user suggested creating two executions. I tried that with no success (meaning I got html, but not xml).
更新你的 POM 文件,因为
这对我来说很有效:可能的原因是它包含最新版本的 cobertura-maven-plugin (2.7)
Update your POM file as
This worked out for me: Probable reason it contanis the latest version of cobertura-maven-plugin (2.7)
将 Cobertura 集成到 Maven 中有两种方法。
The are two ways to integrate Cobertura into Maven.