问题
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>
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?
回答1:
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
uses execution id default-cli
, while your pom.xml
defines configuration in execution with id jacoco-check
bound to phase verify
.
So either use this phase:
mvn verify
Or provide configuration outside of executions
block (i.e. in <plugin><configuration>
) so that it will be inherited in all executions.
Or explicitly specify execution id jacoco-check
:
mvn jacoco:check@jacoco-check
来源:https://stackoverflow.com/questions/57340266/running-jacoco-check-goal-with-maven-3-5