Skip to content


Added profile "code-coverage" to run cobertura-maven-plugin #833

wants to merge 1 commit into from

5 participants


It could be useful to check code coverage and cobertura-maven-plugin will do it.

I've added new profile "code-coverage". You need to activate it and run "mvn clean package" to build report about code coverage. Report about code coverage is available in "target/site/cobertura".



IMHO the best way to add coverage reports is to wait for #785 and add it to the generated site. Maven profiles are not meant for activating build features.

I don't like specifying version numbers by properties. It's overhead that is not needed.

@stefanbirkner stefanbirkner added the maven label

First of all we need to get #787 pushed to master.
We do not need extra profile for code coverage because it should be included in the reporting section of POM.
Then pls remove properties you added, it has no reason on the top since they are used just once. Pls inline them.
After the #787 is pushed, I am open to vote for a code coverage plugin.


About properties: They are used just once, but it is much easier to manage them (to update versions). Each of them in one section, so you shouldn't scan all pom.xml manually.

So, to check updated plugins you need:
1. Run "mvn versions:display-plugin-updates"
2. Open properties section
3. Update needed plugins

JUnit member

If the properties are used once, I would also prefer that they not be in the properties section. I would rather have each plugin standalone. The properties section is essentially a bunch of global variables.

I will ask the other maintainers to see who is the best one to review pom changes.


Actually, properties section is a little bit complicated than a bunch of global variables. You can reassign some properties in profiles or sub-modules. It is also plus in favor of using properties section. :)


That's right, but we don't use profiles and we don't have a multi-module project.


We can move it in build (or reporting) section, but it will take additional time for building project.


This heavy use of properties when they are only used once is a real maven anti-pattern IMHO. But then I'm only on the Apache Maven Project Management Committee so my opinion is probably not relevant!

@vbauer vbauer closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Feb 22, 2014
  1. @vbauer
Showing with 42 additions and 8 deletions.
  1. +42 −8 pom.xml
50 pom.xml
@@ -85,6 +85,16 @@
+ <maven.cobertura.plugin.version>2.6</maven.cobertura.plugin.version>
+ <maven.javadoc.plugin.version>2.9.1</maven.javadoc.plugin.version>
+ <maven.release.plugin.version>2.3.2</maven.release.plugin.version>
+ <maven.gpg.plugin.version>1.4</maven.gpg.plugin.version>
+ <maven.source.plugin.version>2.2</maven.source.plugin.version>
+ <maven.surefire.plugin.version>2.16</maven.surefire.plugin.version>
+ <maven.compiler.plugin.version>2.5.1</maven.compiler.plugin.version>
+ <maven.replacer.plugin.version>1.3.8</maven.replacer.plugin.version>
+ <maven.enforcer.plugin.version>1.1.1</maven.enforcer.plugin.version>
@@ -126,7 +136,7 @@
the project, requires only release versions of dependencies of other artifacts.
- <version>1.1.1</version>
+ <version>${maven.enforcer.plugin.version}</version>
@@ -163,7 +173,7 @@
- <version>1.3.8</version>
+ <version>${maven.replacer.plugin.version}</version>
@@ -186,7 +196,7 @@
java compiler plugin forked in extra process
- <version>2.5.1</version>
+ <version>${maven.compiler.plugin.version}</version>
@@ -206,7 +216,7 @@
our junit suite "AllTests" after the sources are compiled.
- <version>2.16</version>
+ <version>${maven.surefire.plugin.version}</version>
@@ -219,7 +229,7 @@
in to jar archive. See target/junit-*-sources.jar.
- <version>2.2</version>
+ <version>${maven.source.plugin.version}</version>
@@ -228,7 +238,7 @@
in jar archive target/junit-*-javadoc.jar.
- <version>2.9.1</version>
+ <version>${maven.javadoc.plugin.version}</version>
@@ -261,7 +271,7 @@
- <version>2.3.2</version>
+ <version>${maven.release.plugin.version}</version>
@@ -289,7 +299,7 @@
(&ndash;&ndash; stands for double dash)
- <version>1.4</version>
+ <version>${maven.gpg.plugin.version}</version>
@@ -339,5 +349,29 @@
+ <profile>
+ <id>code-coverage</id>
+ <!--
+ Calculate code coverage using Cobertura project
+ Result report is available here: ${}/site/cobertura
+ -->
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>cobertura-maven-plugin</artifactId>
+ <version>${maven.cobertura.plugin.version}</version>
+ <executions>
+ <execution>
+ <phase>package</phase>
+ <goals>
+ <goal>cobertura</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
Something went wrong with that request. Please try again.