Exclude jar file classes from jacoco coverage report

Jacoco code coverage report also includes classes from "system path jar" which I added using below maven dependency

<dependency>
            <groupId>axis</groupId>
            <artifactId>axis</artifactId>
            <version>1.2.1</version>
            <scope>system</scope>
            <systemPath>${project.basedir}/src/main/resources/lib/axis-1.2.1.jar</systemPath>
        </dependency>

      

I tried to exclude this jar files from the jacoco plugin like this:

            <plugin>
                <groupId>org.jacoco</groupId>
                <artifactId>jacoco-maven-plugin</artifactId>
                <version>0.7.2.201409121644</version>
                <configuration>
                    <excludes>
                        <exclude>**/org/apache/**/*</exclude>
                        <exclude>**/org/globus/**/*</exclude>
                    </excludes>
                </configuration>

                <executions>
                    <execution>
                        <id>pre-unit-test</id>
                        <goals>
                            <goal>prepare-agent</goal>
                        </goals>
                        <configuration>
                            <!-- Sets the path to the file which contains the execution data. -->
                            <destFile>${project.build.directory}/coverage-reports/jacoco.exec</destFile>
                            <!-- Sets the name of the property containing the settings for JaCoCo 
                                runtime agent. -->
                            <propertyName>surefireArgLine</propertyName>
                        </configuration>
                    </execution>
                    <execution>
                        <id>post-unit-test</id>
                        <phase>test</phase>
                        <goals>
                            <goal>report</goal>
                        </goals>
                        <configuration>
                            <!-- Sets the path to the file which contains the execution data. -->
                            <dataFile>${project.build.directory}/coverage-reports/jacoco.exec</dataFile>
                            <!-- Sets the output directory for the code coverage report. -->
                            <outputDirectory>${project.reporting.outputDirectory}/jacoco</outputDirectory>
                        </configuration>
                    </execution>
                </executions>
            </plugin>

      

But the exception doesn't work. It still shows the coverage report for the files in the bank. As shown in the figure, the files in the org.apacke folder . and org.clobus. should not appear on the coverage report.

enter image description here

+3


source to share


1 answer


I found an answer from him

 <exclude>**/lib/*</exclude>

      



The above exception excludes classes from my scoped jar file system

.

+3


source







All Articles