Maven Cobertura 插件未生成coverage.xml

发布于 2025-01-08 02:01:18 字数 798 浏览 0 评论 0原文

我试图生成一个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 技术交流群。

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

发布评论

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

评论(8

薄情伤 2025-01-15 02:01:18

将以下行添加到您的应用程序目标:(在 jenkins 中配置应用程序的部分)

cobertura:cobertura -Dcobertura.report.format=xml

pom.xml 更改:

<reporting>
<plugins>
    <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>cobertura-maven-plugin</artifactId>
        <version>2.6</version>
        <configuration>
            <formats>
                <format>html</format>
                <format>xml</format>
            </formats>
        </configuration>
    </plugin>
</plugins>

Add below lines to your application Goals:(configure section of the application in jenkins)

cobertura:cobertura -Dcobertura.report.format=xml

pom.xml changes:

<reporting>
<plugins>
    <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>cobertura-maven-plugin</artifactId>
        <version>2.6</version>
        <configuration>
            <formats>
                <format>html</format>
                <format>xml</format>
            </formats>
        </configuration>
    </plugin>
</plugins>

迷迭香的记忆 2025-01-15 02:01:18

我将插件放在构建部分并且它可以工作:

<build>
    <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>
</build>

报告部分及其与插件部分的差异被描述这里。我不知道这是 Maven [3.0.4] 还是 cobertura-plugin 问题。

I put the plugin in the build section and it works:

<build>
    <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>
</build>

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.

人间不值得 2025-01-15 02:01:18

对于 Maven 插件和 Hudson 及其插件之间的连接,我仍然是一个新手 - 所以这无论如何都不是一个明智的答案,但 Google 上的帮助对于这个问题非常少 - 所以希望它能帮助某人将来。

在花了几个小时修改设置后,我发现coverage.xml似乎根本不是在本地构建的。

这是使它工作的组合:

  1. 我已在 POM 中将版本更改为 2.2(我正在获取资源
    在 2.5.1 中未发现 Apache 的错误)
  2. 在我的 Hudson 目标中添加了 cobertura:cobertura
  3. 将 Cobertura 覆盖模式设置为
    推荐 **/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:

  1. I had changed my version to 2.2 in my POM (I was getting resource
    not found errors from Apache with 2.5.1)
  2. Added cobertura:cobertura in my Hudson goal
  3. Set the Cobertura coverage pattern to the
    recommended **/target/site/cobertura/coverage.xml
耳钉梦 2025-01-15 02:01:18

我的目标是让 Cobertura 在 mvn test 期间运行,无需额外的命令行参数。这是神奇的 XML,它为我提供了帮助,HTML 和 XML 都是在 /target/site/cobertura 中生成的。

<build>
    <plugins>
        <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>cobertura-maven-plugin</artifactId>
            <version>2.7</version>
            <executions>
                <execution>
                    <id>cobertura</id>
                    <phase>test</phase>
                    <goals>
                        <goal>cobertura</goal>
                    </goals>
                    <configuration>
                        <formats>
                            <format>xml</format>
                            <format>html</format>
                        </formats>
                    </configuration>
                </execution>
            </executions>
        </plugin>
    </plugins>
</build>

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.

<build>
    <plugins>
        <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>cobertura-maven-plugin</artifactId>
            <version>2.7</version>
            <executions>
                <execution>
                    <id>cobertura</id>
                    <phase>test</phase>
                    <goals>
                        <goal>cobertura</goal>
                    </goals>
                    <configuration>
                        <formats>
                            <format>xml</format>
                            <format>html</format>
                        </formats>
                    </configuration>
                </execution>
            </executions>
        </plugin>
    </plugins>
</build>
独自←快乐 2025-01-15 02:01:18

我遇到了同样的问题,但现在已经解决了:
只需在 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

眼趣 2025-01-15 02:01:18

我在使用 2.6 插件时遇到了同样的问题。

我发现当我指定这两种类型时,我只得到html。

           <formats>
               <format>html</format>
               <format>xml</format>
           </formats>

但是当我仅指定 xml 时,我会得到一份 xml 报告。

           <formats>
               <format>xml</format>
           </formats>

这可能是插件中的一个错误。

另一位用户建议创建两个执行。我尝试过但没有成功(这意味着我得到了 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.

           <formats>
               <format>html</format>
               <format>xml</format>
           </formats>

But when I specify only xml, I get an xml report.

           <formats>
               <format>xml</format>
           </formats>

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).

终难愈 2025-01-15 02:01:18

更新你的 POM 文件,因为

<build>
<plugins>
    <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>cobertura-maven-plugin</artifactId>
        <version>2.7</version>
        <configuration>
            <formats>
                <format>html</format>
                <format>xml</format>
            </formats>
        </configuration>
    </plugin>
</plugins>

这对我来说很有效:可能的原因是它包含最新版本的 cobertura-maven-plugin (2.7)

Update your POM file as

<build>
<plugins>
    <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>cobertura-maven-plugin</artifactId>
        <version>2.7</version>
        <configuration>
            <formats>
                <format>html</format>
                <format>xml</format>
            </formats>
        </configuration>
    </plugin>
</plugins>

This worked out for me: Probable reason it contanis the latest version of cobertura-maven-plugin (2.7)

烟酉 2025-01-15 02:01:18

将 Cobertura 集成到 Maven 中有两种方法。

  1. 将 Cobertura 放入 pom 文件的 build 部分,然后您必须执行 mvn clean cobertura:cobertura 来生成报告。如果您配置了 XML 和 HTML,那么您将获得这两个报告。
  2. 将Cobertura放入pom文件的报告部分,然后您必须执行mvn clean site来生成报告。如果您配置了 XML 和 HTML,那么您将获得这两个报告。此外,您还可以获得一个生成的网站(打开 target/site/index.html),其中集成了所有报告,例如 Coberture、Checkstyle...

The are two ways to integrate Cobertura into Maven.

  1. Put Cobertura into the build section of the pom file, then you have to execute mvn clean cobertura:cobertura to generate the reports. If you have XML and HTML configured, then you get both reports.
  2. Put Cobertura into the reporting section of the pom file, then you have to execute mvn clean site to generate the reports. If you have XML and HTML configured, then you get both reports. Additionally you get a generated site (open target/site/index.html) with all reports integrated e.g. Coberture, Checkstyle, ...
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文