I am running Jacoco's Maven plugin. The prepare-agent
goal runs fine, but does not generate jacoco.exec
file for some reason. Subsequently the report
goal complains Skipping JaCoCo execution due to missing execution data file
.
Any ideas?
Having read https://groups.google.com/forum/#!topic/jacoco/LzmCezW8VKA, it turns out that prepare-agent
sets a surefire property called argLine
. If you override this property (something that https://issues.apache.org/jira/browse/SUREFIRE-951 encourages you to do) then jacoco never ends up running.
The solution is to replace:
<argLine>-Dfile.encoding=${project.build.sourceEncoding}</argLine>
with
<argLine>-Dfile.encoding=${project.build.sourceEncoding} ${argLine}</argLine>
Meaning, append jacoco's argLine
to the new value.
UPDATE: As pointed out by Fodder, if you aren't always running JaCoCo and no other plugin sets ${argLine}
then Maven will complain that ${argLine}
is undefined. To resolve this, simply define what ${argLine}
should look like when JaCoCo is skipped:
<properties>
<argLine/>
</properties>
In this case use @{argLine} instead of ${argLine} as explained here.