简体   繁体   中英

maven-jacoco-plugin: Build fails after adding class excluding

I am using maven jacoco plugin for code coverage. I decided to exclude some classes from jacoco coverage report. I found here , how to do it.

So my updated pom file looks like this:

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <artifactId>payment-rest</artifactId>
    <packaging>war</packaging>

    <name>payment-rest</name>

    <parent>
        <artifactId>payment-ws</artifactId>
        <groupId>com.example.foo</groupId>
        <version>1.0.0-INTEGRATION-SNAPSHOT</version>
    </parent>

    <properties>
        <jacoco.line.coverage>0.78</jacoco.line.coverage>
        <jacoco.branch.coverage>1.00</jacoco.branch.coverage>
        <servlet.version>3.0.1</servlet.version>
    </properties>

    <dependencies>

     <!-- all dependecies here-->
    </dependencies>

    <build>
        <finalName>payment-ws</finalName>
        <plugins>
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>sonar-maven-plugin</artifactId>
            </plugin>
            <plugin>
                <groupId>org.jacoco</groupId>
                <artifactId>jacoco-maven-plugin</artifactId>
                <configuration>
                    <excludes>
                        <exclude>
                            **/com/example/foo/payment/configuration/**.*
                        </exclude>
                    </excludes>
                </configuration>
            </plugin>
            <plugin>
                <artifactId>maven-war-plugin</artifactId>
                <configuration>
                    <attachClasses>true</attachClasses>
                    <classesClassifier>classes</classesClassifier>
                    <failOnMissingWebXml>false</failOnMissingWebXml>
                </configuration>
            </plugin>
        </plugins>
    </build>
</project>

So, when I am running mvn clean install command, I gets this error ():

Execution default-test of goal org.apache.maven.plugins:maven-surefire-plugin:2.19:test failed: The forked VM terminated without properly saying goodbye. VM crash or System.exit called?

在此处输入图片说明

If I remove exclusion part, project builds successfully.

Can someone advise me how can I solve this issue?

issue is occur because maven-surefire-plugin is missing into your project pom.xml . you need to add this plugin into pom.xml , after adding need to update and rebuild the project and run it.

you can find the maven plugin below:

 <plugins>
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-surefire-plugin</artifactId>
          <version>2.19.1</version>
        </plugin>
  </plugins>

you can refer higher version from 2.19.1 .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM