且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何从命令行配置JaCoCo Maven插件

更新时间:2023-09-17 15:02:22

更新为0.7.8

GitHub问题322 已从

Update to 0.7.8

The GitHub issue 322 has been resolved as of version 0.7.8 of the jacoco-maven-plugin. Starting from this version, you can use the user property jacoco.dataFile, so the commands in the question would work as-is.

要在命令行上强制版本,您应该具有:

To force the version on the command line, you should have:

mvn -Djacoco.destFile=./coverage/jacoco.exec clean org.jacoco:jacoco-maven-plugin:0.7.8:prepare-agent install

您还可以在POM中配置jacoco-maven-plugin并明确指定此版本.

You can also configure the jacoco-maven-plugin inside your POM and specify this version explicitly.

在版本0.7.8之前,没有用户属性作为dataFile属性,因此您将无法执行此操作.调用时,您正确地覆盖了默认值

Before version 0.7.8, there is no user property for the dataFile attribute, so you won't be able to do that. You are correctly overriding the default value when you're invoking

mvn -Djacoco.destFile=./coverage/jacoco.exec clean org.jacoco:jacoco-maven-plugin:prepare-agent install

因为 jacoco.destFile 是名称与prepare-agent目标的destFile属性相关联的用户属性.

because jacoco.destFile is the name of the user property associated with the destFile attribute of the prepare-agent goal.

但是,相应的 dataFile没有用户属性 report目标的属性.因此,***的选择是保留默认值.

However, there are no user property for the corresponding dataFile attribute of the report goal. So your best bet would be to keep the default.