jacoco的prepare-agent不生成jacoco.exec文件 [英] jacoco's prepare-agent not generating jacoco.exec file
问题描述
我正在运行Jacoco的Maven插件. prepare-agent
目标运行良好,但由于某种原因未生成jacoco.exec
文件.随后report
目标抱怨Skipping JaCoCo execution due to missing execution data file
.
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
.
有什么想法吗?
推荐答案
已阅读 https://groups.google.com/forum/#!topic/jacoco/LzmCezW8VKA ,事实证明prepare-agent
设置了一个名为argLine
的surefire属性.如果您覆盖此属性( https://issues.apache.org/jira/browse /SUREFIRE-951 鼓励您这样做),那么jacoco永远不会停止运行.
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.
解决方案是替换:
<argLine>-Dfile.encoding=${project.build.sourceEncoding}</argLine>
使用
<argLine>-Dfile.encoding=${project.build.sourceEncoding} ${argLine}</argLine>
意思是,将jacoco的argLine
附加到新值.
Meaning, append jacoco's argLine
to the new value.
更新:如 Fodder 所述,如果您并非总是运行JaCoCo并且没有其他插件集${argLine}
,那么Maven将抱怨${argLine}
未定义.要解决此问题,只需定义跳过JaCoCo时${argLine}
的外观:
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>
在这种情况下,请使用@ {argLine}代替$ {argLine},如此处所述.
In this case use @{argLine} instead of ${argLine} as explained here.
这篇关于jacoco的prepare-agent不生成jacoco.exec文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!