4

I have many projects which inherit from a parent pom. I enable Cobertura coverage reports in the parent via a Maven profile that is activated in our Jenkins CI builds. However, I want to disable Cobertura for one child project (while getting everything else from the parent pom). What is the best way to achieve this?

My first thought is to use :

                    <configuration>
                        <instrumentation>
                            <excludes>
                                <exclude>**/*.class</exclude>
                            </excludes>
                        </instrumentation>

but I'd rather just skip the entire step and not generate an "empty" Coverage report.

djb
  • 4,930
  • 1
  • 34
  • 37

1 Answers1

6

Use the 'skip' configuration item as documented cobertura-maven-plugin.

Efthymis
  • 1,326
  • 11
  • 13
bmargulies
  • 97,814
  • 39
  • 186
  • 310
  • thanks @bmargulies. I added true to the child pom and running help:effective-pom verifies it, but Cobertura still instrumented all the classes. I see that skip was added in 2.5 - I have been using 2.4. So, this answer sounds like a winner. – djb Oct 14 '11 at 17:17
  • 1
    I confess that I'm probably the person who added skip to 2.5. – bmargulies Oct 14 '11 at 17:24
  • I found that I had to add a maven-antrun-plugin target to because our Jenkins CI is configured (generically) to publish artifacts from " target/surefire-reports/**/*,target/cobertura/**/*,target/lib/**/*,target/*.jar,target/*.txt " and this was causing the Jenkins build to fail with true. This way, I can just change true to false and everything will work and artifacts get published. – djb Oct 14 '11 at 20:06
  • Within our Jenkins CI env, which expects to publish Cobertura projects for all projects, I also had to create a stub site/covertura/coverage.xml file (I did this in an antrun target) so that the Jenkins build would succeed. (I know I could disable 'Publish Cobertura Coverage Report' in the Jenkins project config, but we prefer to have uniform project configurations, i.e. no exceptions: we generate the Jenkins config from a simple template) – djb Oct 17 '11 at 14:21