Maven Cobertura plugin not generating coverage.xml

kjl picture kjl · Feb 22, 2012 · Viewed 33.6k times · Source

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

Answer

Sreedhar GS picture Sreedhar GS · Jun 5, 2014

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>