SonarQube Java :: JaCoCo Listeners generates huge jacoco.exec report

1.6k views Asked by At

Ive got a middle to large scaled project with ~150k LOC. Jacoco maven-plugin generates reports on each and every unit test to the file jacoco.exec.

So, basically this is the surefire setup in pom.xml:

<plugin>
     <groupId>org.apache.maven.plugins</groupId>
     <artifactId>maven-surefire-plugin</artifactId>
     <version>2.17</version>
     <configuration>
      <argLine>-XX:-UseSplitVerifier</argLine>
      <includes>
       <include>**/*Test.java</include>
       <include>**/*Tests.java</include>
      </includes>
      <excludes>
       <exclude>**/it/*IT.java</exclude>
       <exclude>**/*IT.java</exclude>
      </excludes>
                        <properties>
                            <property>
                                <name>listener</name>
                                <value>org.sonar.java.jacoco.JUnitListener</value>
                            </property>
                        </properties>
     </configuration>
    </plugin>
 <plugin>

The tricky part being the JUnitListener. The target jacoco.exec file becomes 4,5 Gb large (huge!). Once our Jenkins CI slaves starts processing the file, the sonar runner (maven artifact as well) tries to load the entire file into memory - or so it seems. And that requires Heap size of 8 gig.. This seems entirely wrong, doesnt it?

Question here is, can anything be done to minimize the size of jacoco.exec? We are restricted to Java 1.6 SDK (have noticed size becoming < 2 Gb with Java 1.7). Im guessing the debug symbols are a nescessity for creating the coverage report or am i wrong?

1

There are 1 answers

0
Peter On

clean jacoco .exec file before running. it seems that jacoco is appending to existing file. adding the jacoco listener increases the file size significantly. after a few runs you got GB files. i also had experienced that sonarqube cannot parse files with > 4 GB. or you can explizit set append to false. this is a gradle example:

test {
    jacoco {
        append = false
        destinationFile = file("$buildDir/jacoco/jacocoTest.exec")
    }
}