Ignoring report generation for specific classes in cobertura maven plugin

Neeraj picture Neeraj · Mar 7, 2011 · Viewed 12.4k times · Source

I've been using Cobertura plugin for report generation and instrumentation (with surefire). Here is the issue I am facing:

I am unable to make the plugin ignore report generation for specific classes in my project.

PF below the related excerpt from pom.xml, I have added the ignore tag, but that just ignores instrumentation for the ignored classes.

I want the report for specific projects to not be generated at all.

Firstly, due to my limited knowledge of both Maven and Conberture, I want to know is it possible, and if yes, then what are the changes I need to get done in pom.xml.

pom.xml

<report>
    <!-- other plugins exist but are not important to be listed here I guess -->   
    <plugin>
        <artifactId>maven-surefire-plugin</artifactId>
        <configuration>
            <skipTests>false</skipTests>
            <systemProperties>
                <property>
                <name>net.sourceforge.cobertura.datafile</name>
                <value>target/cobertura/cobertura.ser</value>
                </property>
            </systemProperties>
        </configuration>
    </plugin>
    <!-- The following is the plugin for cobertura, which takes care of integration and report generation-->
    <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>cobertura-maven-plugin</artifactId>
        <configuration>
            <check>
                <branchRate>50</branchRate>
                <lineRate>50</lineRate>
                <haltOnFailure>true</haltOnFailure>
                <totalBranchRate>50</totalBranchRate>
                <totalLineRate>50</totalLineRate>
                <packageLineRate>50</packageLineRate>
                <packageBranchRate>50</packageBranchRate>
            </check>
            <instrumentation>
                <ignores>
                  <ignore>deshaw.dportal.alert.*</ignore>
                  <ignore>deshaw.dportal.atc.*</ignore>
                  <ignore>deshaw.dportal.basket.*</ignore>
                  <ignore>deshaw.dportal.fcs.*</ignore>
                  <ignore>deshaw.dportal.event.*</ignore>
                  <ignore>deshaw.dportal.filings.*</ignore>
                  <ignore>deshaw.dportal.glg.*</ignore>
                  <ignore>deshaw.dportal.icp.*</ignore>
                </ignores>
            </instrumentation>
        </configuration>
    </plugin>
</report>

Edit:

This my directory structure:

module
|
|-apps
|    |-alert
|    |    |-src
|    |    |-target
|    |    |-pom.xml
|    |-------------------
|    |-company
|    |    |-src
|    |    |-target
|    |    |-pom.xml
|-----------------------
|-jobs
|    |-job1
|    |    |-src
|    |    |-target
|    |    |-pom.xml
|    |-job2
|    |    |-src
|    |    |-target
|    |    |-pom.xml

I tried the following in module/pom.xml

<instrumentation>
    <excludes>
        <exclude>**/apps/*.*</exclude>
    </excludes>
</instrumentation>

I still get the reports being generated in both the alerts and company directory.

Probably the exclude regex is not right?

Answer

Neeraj picture Neeraj · Mar 15, 2011

Cobertura maven plugin does not respect exclusion and ignoring for report generation.It does so for instrumentation though.

Known bug reported at : http://jira.codehaus.org/browse/MCOBERTURA-52