Skip to content

Loading…

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

Closed
wants to merge 1 commit into from

5 participants

@vbauer

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".

image

@stefanbirkner

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
@Tibor17

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.

@vbauer

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

@kcooney
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.

@vbauer

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. :)

@stefanbirkner

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

@vbauer

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

@stephenc

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
View
50 pom.xml
@@ -85,6 +85,16 @@
<project.build.sourceEncoding>ISO-8859-1</project.build.sourceEncoding>
<arguments/>
<gpg.keyname>67893CC4</gpg.keyname>
+
+ <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>
</properties>
<dependencies>
@@ -126,7 +136,7 @@
the project, requires only release versions of dependencies of other artifacts.
-->
<artifactId>maven-enforcer-plugin</artifactId>
- <version>1.1.1</version>
+ <version>${maven.enforcer.plugin.version}</version>
<executions>
<execution>
<id>enforce-versions</id>
@@ -163,7 +173,7 @@
-->
<groupId>com.google.code.maven-replacer-plugin</groupId>
<artifactId>maven-replacer-plugin</artifactId>
- <version>1.3.8</version>
+ <version>${maven.replacer.plugin.version}</version>
<executions>
<execution>
<phase>process-sources</phase>
@@ -186,7 +196,7 @@
java compiler plugin forked in extra process
-->
<artifactId>maven-compiler-plugin</artifactId>
- <version>2.5.1</version>
+ <version>${maven.compiler.plugin.version}</version>
<configuration>
<encoding>${project.build.sourceEncoding}</encoding>
<source>${jdkVersion}</source>
@@ -206,7 +216,7 @@
our junit suite "AllTests" after the sources are compiled.
-->
<artifactId>maven-surefire-plugin</artifactId>
- <version>2.16</version>
+ <version>${maven.surefire.plugin.version}</version>
<configuration>
<test>org/junit/tests/AllTests.java</test>
<useSystemClassLoader>true</useSystemClassLoader>
@@ -219,7 +229,7 @@
in to jar archive. See target/junit-*-sources.jar.
-->
<artifactId>maven-source-plugin</artifactId>
- <version>2.2</version>
+ <version>${maven.source.plugin.version}</version>
</plugin>
<plugin>
<!--
@@ -228,7 +238,7 @@
in jar archive target/junit-*-javadoc.jar.
-->
<artifactId>maven-javadoc-plugin</artifactId>
- <version>2.9.1</version>
+ <version>${maven.javadoc.plugin.version}</version>
<configuration>
<stylesheetfile>${basedir}/src/main/javadoc/stylesheet.css</stylesheetfile>
<show>protected</show>
@@ -261,7 +271,7 @@
</plugin>
<plugin>
<artifactId>maven-release-plugin</artifactId>
- <version>2.3.2</version>
+ <version>${maven.release.plugin.version}</version>
<configuration>
<mavenExecutorId>forked-path</mavenExecutorId>
<useReleaseProfile>false</useReleaseProfile>
@@ -289,7 +299,7 @@
(&ndash;&ndash; stands for double dash)
-->
<artifactId>maven-gpg-plugin</artifactId>
- <version>1.4</version>
+ <version>${maven.gpg.plugin.version}</version>
<executions>
<execution>
<id>gpg-sign</id>
@@ -339,5 +349,29 @@
</plugins>
</build>
</profile>
+ <profile>
+ <id>code-coverage</id>
+ <!--
+ Calculate code coverage using Cobertura project
+ Result report is available here: ${build.directory}/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>
</profiles>
</project>
Something went wrong with that request. Please try again.