Skip to content
Gahan Rakholia edited this page Jan 18, 2020 · 6 revisions

The basic usage will use all the default values as describled in the Goals.

Basic Example

<project>
  ...
  <build>
    <plugins>
      <plugin>
        <groupId>io.github.handofgod94</groupId>
        <artifactId>jacoco-cov-badge-maven-plugin</artifactId>
        <version>1.1.0</version>
      </plugin>
    </plugins>
  </build>
   ...
</project>

Here, if nothing is specified, the plugin will be bound to verify phase. It is also assumed that jacoco.csv report is availbe during the exectuion of the phase.

Generating PNG, JPG Badges

To generage png or jpg badges all you have to do is specify correct extension in outputFile config.

<project>
  ...
  <build>
    <plugins>
      <plugin>
        <groupId>io.github.handofgod94</groupId>
        <artifactId>jacoco-cov-badge-maven-plugin</artifactId>
        <version>1.1.0</version>
         <executions>
            <execution>
            <id>generate-badge</id>
            <phase>post-site</phase>
            <configuration>
                <outputFile>${project.build.directory}/coverage.png</outputFile>
            </configuration>
            <goals>
                <goal>badge</goal>
            </goals>
            </execution>
        </executions>
      </plugin>
    </plugins>
  </build>
   ...
</project>

If unknown format is specified then by default svg badge will be generated.

Generate badges different coverage categories

You can specify coverageCategory enum to calculate and generate badges for different category from jacoco report.
See goals for more info on different category options available.

<project>
  ...
  <build>
    <plugins>
      <plugin>
        <groupId>io.github.handofgod94</groupId>
        <artifactId>jacoco-cov-badge-maven-plugin</artifactId>
        <version>1.1.0</version>
         <executions>
            <execution>
            <id>generate-badge</id>
            <phase>post-site</phase>
            <configuration>
                <!-- Refer Goals page to know all the parameters that can be specified -->
                <coverageCategory>METHOD</coverageCategory>
                <outputFile>${project.build.directory}/coverage.png</outputFile>
            </configuration>
            <goals>
                <goal>badge</goal>
            </goals>
            </execution>
        </executions>
      </plugin>
    </plugins>
  </build>
   ...
</project>
Clone this wiki locally