Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-21658

Provide option to exclude complete Maven modules from JaCoCo report

    • Icon: New Feature New Feature
    • Resolution: Unresolved
    • Icon: Major Major
    • jacoco-plugin
    • None

      We need an option to exclude complete Maven modules from the JaCoCo report.

      I've tried it with an exclusion pattern like **/module-to-be-excluded/**, but this doesn't work. It seems that the JaCoCo plugin copies the classes from all modules into a new directory, so the module folder names are lost and cannot be used for filtering any more.

      Filtering on package/class level would be very cumbersome because other modules in the build typically use similar package names.

      Thanks a lot for your assistance!

      Best Regards,

      Jochen Ehret.

          [JENKINS-21658] Provide option to exclude complete Maven modules from JaCoCo report

          Philip Aston added a comment -

          I have the same problem. The includes/excludes appear to be evaluated relative to the class directory. It is onerous and brittle to add specific exclusions on a package by package basis.

          IMHO, rather than an option to exclude specific maven modules, the plugin should ignore un-instrumented class files.

          This would address the problem without being maven specific. In the maven configuration, modules could then be excluded by configuring them to skip jacoco instrumentation...

          <plugin>
              <groupId>org.jacoco</groupId>
              <artifactId>jacoco-maven-plugin</artifactId>
              <configuration>
                  <skip>true</skip>
              </configuration>
          </plugin>
          

          ... and code within modules to be excluded by configuring the agent to be more selective ...

          <plugin>
              <groupId>org.jacoco</groupId>
              <artifactId>jacoco-maven-plugin</artifactId>
              <version>${jacoco-plugin.version}</version>
              <executions>
                  <execution>
                      <goals>
                          <goal>prepare-agent</goal>
                      </goals>
                      <configuration>
                          <includes>
                              <include>com.foo.*</include>
                          </includes>
                      </configuration>
                  </execution>
              </executions>
          </plugin>
          

          Philip Aston added a comment - I have the same problem. The includes/excludes appear to be evaluated relative to the class directory. It is onerous and brittle to add specific exclusions on a package by package basis. IMHO, rather than an option to exclude specific maven modules, the plugin should ignore un-instrumented class files. This would address the problem without being maven specific. In the maven configuration, modules could then be excluded by configuring them to skip jacoco instrumentation... <plugin> <groupId>org.jacoco</groupId> <artifactId>jacoco-maven-plugin</artifactId> <configuration> <skip> true </skip> </configuration> </plugin> ... and code within modules to be excluded by configuring the agent to be more selective ... <plugin> <groupId>org.jacoco</groupId> <artifactId>jacoco-maven-plugin</artifactId> <version>${jacoco-plugin.version}</version> <executions> <execution> <goals> <goal>prepare-agent</goal> </goals> <configuration> <includes> <include>com.foo.*</include> </includes> </configuration> </execution> </executions> </plugin>

            ognjenb Ognjen Bubalo
            jochenehret Jochen Ehret
            Votes:
            2 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated: