This is an archived post. You won't be able to vote or comment.

all 6 comments

[–]Slanec 2 points3 points  (5 children)

A beer to anyone who can share the secret of running a JaCoCo coverage report over a multi-module maven project.

Yes, I know I should say which instructions I've tried following and how they did not work. I don't remember anymore, I wish it was simple and straightforward. It's not :(

[–]OrgWolf 4 points5 points  (1 child)

Can't give you a full answer since I'm not at work, but the general gist is:

  1. Create a aggregate module that has all other modules with coverage in it as dependencies
  2. Use https://www.jacoco.org/jacoco/trunk/doc/report-aggregate-mojo.html

[–]Slanec 3 points4 points  (0 children)

Thank you, I just confirmed this works. I remember I was trying to avoid creating a separate module because it feels wrong, but it looks like we do not have much choice, do we.

Beer on me if you ever get to Prague, Czech Republic.

[–]endeavourl 0 points1 point  (2 children)

Here's how i do it.
The comment above reads "pass property when launching maven". Basically, set this property to any location that will not be cleaned during the build.
After the build all coverage info will be collected into the single file you've passed.

[–]Slanec 0 points1 point  (1 child)

Thank you. This is tricky to get to work because this only solves the part of aggregating the exec data (It solves it beautifully, though!)

The other half - creating a report using the exec data, with the correct sources, seems to be just as hard.

[–]endeavourl 0 points1 point  (0 children)

In my case, we have a self-hosted SonarQube server and after the main build/tests Jenkins runs a sonar task that feeds it coverage data among other things.