For all our projects I had to enable JaCoCo reporting to send the code coverage reports to Sonar. This went fine for almost all projects, however some of them had 0% coverage.

Maven plugin looks like this:

<plugin>
    <groupId>org.jacoco</groupId>
    <artifactId>jacoco-maven-plugin</artifactId>
    <version>0.8.2</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>

However if you have configured maven-surefire-plugin where you have a argLine then the JaCoCo argline will be overwritten.

Solution is to pass $argLine to the <argLine> so the JaCoCo args are appended:

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-surefire-plugin</artifactId>
    <version>2.22.2</version>
    <configuration>
        <argLine>-Xmx1024m -Dproperty=value ${argLine}</argLine>
    </configuration>
</plugin>