Generate report from merged jacoco exec files

1,872 views
Skip to first unread message

gmpark...@gmail.com

unread,
May 8, 2017, 3:04:45 PM5/8/17
to JaCoCo and EclEmma Users
Hoping someone can help me out. I have the following in my reactor pom :

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.19.1</version>
<configuration>
<argLine>${surefireArgLine} -Xms256m -Xmx2048m</argLine>
<forkCount>1</forkCount>
<runOrder>random</runOrder>
<testFailureIgnore>true</testFailureIgnore>
</configuration>
</plugin>

<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.7.9</version>
<configuration>
<propertyName>surefireArgLine</propertyName>
</configuration>
<executions>
<execution>
<id>prepare-agent</id>
<goals>
<goal>prepare-agent</goal>
</goals>
</execution>
</executions>
</plugin>


In a seperate reporting pom I have this:

<reporting>
<plugins>

<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.7.9</version>
<inherited>true</inherited>
<reportSets>
<reportSet>
<reports>
<report>report-aggregate</report>
</reports>
</reportSet>
</reportSets>
</plugin>
</plugins>
</reporting>

<build>

<plugins>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.7.9</version>
<inherited>true</inherited>
<executions>
<execution>
<phase>verify</phase>
<goals>
<goal>merge</goal>
</goals>
</execution>
</executions>
<configuration>
<destFile>${project.build.directory}/jacoco.exec</destFile>
<fileSets>
<fileSet implementation="org.apache.maven.shared.model.fileset.FileSet">
<directory>${basedir}/..</directory>
<includes>
<include>**/target/*.exec</include>
</includes>
</fileSet>
</fileSets>
</configuration>
</plugin>
</plugins>
</build>

So the idea is that I build my multi-module project which generates multiple jacoco.exec files. Then I execute a build on the reporting project to merge the individual jacoco.exec files and executes a report. The individual jacoco.exec files all work and have data. The merge seems to work as well but the final report has nothing. Is everything that the jacoco reporting plugin requires in the jacoco.exec file or does it require jar files/classes as well?

Marc R. Hoffmann

unread,
May 8, 2017, 3:48:53 PM5/8/17
to jac...@googlegroups.com
Hi,

hard to tell what's going wrong here as you only show snippets. In our
test suite you find a working example:

https://github.com/jacoco/jacoco/tree/master/jacoco-maven-plugin.test/it/it-report-aggregate

Does you reporting pom declare dependencies on on the projects which
should be included? " The report is created from all modules this
project depends on". See documentation:

http://www.jacoco.org/jacoco/trunk/doc/report-aggregate-mojo.html

Regards,
-marc

gmpark...@gmail.com

unread,
May 8, 2017, 7:05:18 PM5/8/17
to JaCoCo and EclEmma Users
That makes sense. I was hoping that there was a way to generate a report using just the jacoco.exec file. The project that is generating the report is not part of multi module project. During the multi-module build, individual jacoco.exec files are created. Later, the report project is built and a jacoco merge takes place to build a merged jacoco.exec file. Then I was trying to run the report on the merged jacoco.exec file. Can this be done? Does the report process need class files, source files, etc etc? Or is the execution data enough?

Marc R. Hoffmann

unread,
May 9, 2017, 1:14:26 AM5/9/17
to jac...@googlegroups.com
Hi,

exec files are basically plain arrays of boolean probes. Beside the name
and hash they do not contain any information about the corresponding
class files. During report generation the original class files are used
to analyze the control flow and calculate coverage for lines, methods
and so on.

Therefore JaCoCo always requires class files to generate reports. Source
files are optional, but without them you don't get source highlighting
in the HTML report of course.

Regards,
-marc
Reply all
Reply to author
Forward
This conversation is locked
You cannot reply and perform actions on locked conversations.
0 new messages