How to specify output format for jacoco plugin for maven?

Viktoria picture Viktoria · Oct 2, 2018 · Viewed 8.7k times · Source

I have a maven project with jacoco plugin, which generates reports in different formats, such as html, csv and xml. But I need only html. How can I specify it?

Here is some code, where I add jacoco plugin:

<build>
    <plugins>
        <plugin>
            <groupId>org.jacoco</groupId>
            <artifactId>jacoco-maven-plugin</artifactId>
            <version>${jacoco.plugin.version}</version>
            <executions>
                <execution>
                    <goals>
                        <goal>prepare-agent</goal>
                    </goals>
                </execution>
                <execution>
                    <id>report</id>
                    <phase>test</phase>
                    <goals>
                        <goal>report</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>
    //other plugins
    </plugins>
</build>

Then I run tests:

mnv clean test

And all reports appears in "target" directory.

I read documentation https://www.eclemma.org/jacoco/trunk/doc/maven.html, but I didn't found anything about how to pick requiring format. I found it only for Ant and Gradle.

I suppose I missing something, so I will be grateful for any clue.

Answer

Godin picture Godin · Oct 2, 2018

As of today report goal of jacoco-maven-plugin unconditionally generates XML, HTML and CSV - see https://github.com/jacoco/jacoco/issues/9

And in my opinion there is no reasons to disable HTML and XML - cost of generation is small, developers can view HTML in place, while XML consumed by other tools such as SonarQube or Jenkins.

As a workaround if highly needed, report task of JaCoCo Ant Tasks can be executed via maven-antrun-plugin.