ERROR in jacoco check - The parameters 'rules' are missing or invalid
Asked Answered
E

1

10

This is the error I get when running mvn jacoco:check for a maven application. Due to that, the report is not generated.

 [ERROR] Failed to execute goal org.jacoco:jacoco-maven-plugin:0.8.3:check (default-cli) on project 

    Netflix: The parameters 'rules' for goal org.jacoco:jacoco-maven-plugin:0.8.3:check are missing or invalid -> [Help 1]
    org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.jacoco:jacoco-maven-plugin:0.8.3:check (default-cli) on project Netflix: The parameters 'rules' for goal org.jacoco:jacoco-maven-plugin:0.8.3:check are missing or invalid
        at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:215)
        at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:156)
        at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:148)

This is my jacoco plugin in pom.xml. I think the rules are all okay. I'd like to know what's missing...

<plugin>
            <groupId>org.jacoco</groupId>
            <artifactId>jacoco-maven-plugin</artifactId>
            <version>0.8.2</version>
            <executions>
                <execution>
                    <id>default-prepare-agent</id>
                    <phase>test</phase>
                    <goals>
                        <goal>prepare-agent</goal>
                    </goals>
                    <configuration>
                        <!-- Sets the path to the file which contains the execution data. -->
                        <destFile>target/coverage-reports/jacoco-ut.exec</destFile>
                    </configuration>
                </execution>
                <execution>
                    <id>default-report</id>
                    <phase>test</phase>
                    <goals>
                        <goal>report</goal>
                    </goals>
                </execution>
                <execution>
                    <id>default-jacoco-check</id>
                    <phase>test</phase>
                    <goals>
                        <goal>check</goal>
                    </goals>
                    <configuration>
                        <rules>
                            <rule>
                                <element>PACKAGE</element>
                                <limits>
                                    <limit>
                                        <counter>LINE</counter>
                                        <value>COVEREDRATIO</value>
                                        <minimum>0.00</minimum>
                                    </limit>
                                    <limit>
                                        <counter>BRANCH</counter>
                                        <value>COVEREDRATIO</value>
                                        <minimum>0.00</minimum>
                                    </limit>
                                </limits>
                            </rule>
                        </rules>
                    </configuration>
                </execution>
                <execution>
                    <id>post-integration-test</id>
                    <phase>post-integration-test</phase>
                    <goals>
                        <goal>report</goal>
                    </goals>
                    <configuration>
                        <dataFile>target/coverage-reports/jacoco-it.exec</dataFile>
                        <outputDirectory>target/coverage-reports/jacoco-it</outputDirectory>
                    </configuration>
                </execution>
            </executions>
        </plugin>
Enact answered 12/5, 2020 at 11:51 Comment(2)
Does this answer your question? Running jacoco check goal with maven 3.5Brigade
Would be useful if jacoco/maven provided details rather than just "There was an error".Justino
S
22

The jacoco:check goal is attached to Maven verify phase. You can check the same in jacoco:check

You need to run it using maven verify phase

mvn clean verify
Sizzle answered 12/5, 2020 at 12:36 Comment(2)
Is there an explanation to why this will succeed but running mvn jacoco:check specifically fails? I'm new to and trying to understand how maven works.Hydrochloride
@KwesiSmart probably this answer helps to understand. I'm also new, didn't understand much but there's some level of explanation at least https://mcmap.net/q/1161971/-running-jacoco-check-goal-with-maven-3-5Universalism

© 2022 - 2024 — McMap. All rights reserved.