使用Maven 3.5运行Jacoco检查目标 [英] Running jacoco check goal with maven 3.5
问题描述
我在pom中的jacoco插件配置如下所示
My jacoco plugin configuration in a pom likes below
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.7.5.201505241946</version>
<executions>
<execution>
<id>pre-unit-test</id>
<goals>
<goal>prepare-agent</goal>
</goals>
<configuration>
<destFile>${jacoco.ut.execution.data.file}</destFile>
</configuration>
</execution>
<execution>
<id>merge-execs</id>
<phase>pre-site</phase>
<inherited>false</inherited>
<goals>
<goal>merge</goal>
</goals>
<configuration>
<fileSets>
<fileSet>
<directory>${basedir}</directory>
<includes>
<include>**/target/*.exec</include>
</includes>
</fileSet>
</fileSets>
<destFile>${jacoco.ut.merged.exec}</destFile>
</configuration>
</execution>
<execution>
<id>jacoco-check</id>
<phase>verify</phase>
<goals>
<goal>check</goal>
</goals>
<configuration>
<rules>
<rule>
<element>BUNDLE</element>
<limits>
<limit>
<counter>LINE</counter>
<value>COVEREDRATIO</value>
<minimum>0.80</minimum>
</limit>
</limits>
</rule>
</rules>
<dataFile>${jacoco.ut.merged.exec}</dataFile>
</configuration>
</execution>
</executions>
</plugin>
但是当我运行mvn jacoco:check
时,它失败并显示以下错误
But when I am running mvn jacoco:check
it is failing with the below error
[ERROR] Failed to execute goal org.jacoco:jacoco-maven-plugin:0.7.5.201505241946:check (default-cli) on project main: The parameters 'rules' for goal org.jacoco:jacoco-maven-plugin:0.7.5.201505241946:check are missing or invalid -> [Help 1]
有人可以让我知道发生了什么事吗?
Can someone let me know what is going wrong?
推荐答案
您观察到的行为并非特定于jacoco-maven-plugin
,这是Maven的工作方式-请参见
Behavior that you observe is not specific to jacoco-maven-plugin
, it is how Maven works - see https://maven.apache.org/guides/mini/guide-default-execution-ids.html
mvn jacoco:check
使用执行ID default-cli
,而您的pom.xml
定义执行时ID为jacoco-check
绑定到阶段verify
的配置.
uses execution id default-cli
, while your pom.xml
defines configuration in execution with id jacoco-check
bound to phase verify
.
因此请使用此阶段:
mvn verify
或在executions
块之外(即在<plugin><configuration>
中)提供配置,以便它将在所有执行中继承.
Or provide configuration outside of executions
block (i.e. in <plugin><configuration>
) so that it will be inherited in all executions.
或明确指定执行ID jacoco-check
:
Or explicitly specify execution id jacoco-check
:
mvn jacoco:check@jacoco-check
这篇关于使用Maven 3.5运行Jacoco检查目标的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!