3

Hi I am trying to exclude classes for my code coverage using jacoco. I want to exclude the gui folder and all the classes inside it.

   <configuration>
      <excludes>
          <exclude>com.project/folder/tools/gui/*.class</exclude>
      </excludes>
      </configuration>

com.project -> folder -> tools -> gui

I have tried many different paths but for some reason it wont exclude any of them. Am I doing this wrong? Can anyone point me in the right direction.

Tunaki
  • 132,869
  • 46
  • 340
  • 423
hat_to_the_back
  • 99
  • 1
  • 12

3 Answers3

0

I have also faced the same problem.In my case ,I was trying to generate code coverage of a application which was running on j2EE server. I have tried to remove some classes which were not getting used much , to increase code coverage, but exclude does not worked for me.

At last i have tried work around for this instead of using exclude in to configuration. I have removed the clasess from the path of the task that was responsible for generating report.

prashant
  • 39
  • 5
  • How did you do that might I ask. It really is quite annoying – hat_to_the_back Jul 31 '14 at 10:53
  • I have created two tasks , one for generating code coverage file(exe file) and another for generating report . In th second task , i have provided only those classes which i want to be included in to the result. – prashant Jul 31 '14 at 11:07
0

Maven include/exclude syntax is Ant. So I suggest you to have a look on fileset documentation, where you can find few illustrative examples.

In your particular configuration, it could work this pattern

**/gui/**

assuming that you don't use the package name "gui" in other context.

0

We can exclude the class from coverage checking (i.e. fail the build if the coverage doesn't meet the target), but not exclude them from the reporting (i.e. you can still see the class in the report). Is it what you after?

If you would like to exclude the classes from checking, you could try the following config, and please use com.project.folder.tools.gui.* pattern without the slash and trailing suffix.

<plugin>
    <groupId>org.jacoco</groupId>
    <artifactId>jacoco-maven-plugin</artifactId>
    <executions>
        <execution>
            <id>check</id>
            <goals>
                <goal>check</goal>
            </goals>
            <configuration>
            <haltOnFailure>true</haltOnFailure>
            <rules>
                <rule>
                    <element>CLASS</element>
                    <excludes>
                        <exclude>com.example.className</exclude>
                        <exclude>com.example.config.*</exclude>
                    </excludes>
                    <limits>
                        <limit>
                            <counter>LINE</counter>
                            <value>COVEREDRATIO</value>
                            <minimum>0.80</minimum>
                        </limit>
                    </limits>
                </rule>
            </rules>
            </configuration>
         </execution>
     </executions>
 </plugin>

Check this offical doco for detail

Eric Tan
  • 1,377
  • 15
  • 14