Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Next challenges

Recent achievements

  • Global
  • Personal

Recognition

  • Give kudos
  • Received
  • Given

Leaderboard

  • Global

Trophy case

Kudos (beta program)

Kudos logo

You've been invited into the Kudos (beta program) private group. Chat with others in the program, or give feedback to Atlassian.

View group

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

How to integrate Clover in my Maven 3 builds?

I am trying to add Clover to my existing multi-module project but I'm failing miserably. I sure could use some help.

At this moment there are already JUnit tests in the projects and Checkstyle, FindBugs and PMD are bound to the 'verify' phase.

I run my builds with just 'mvn clean install' and everything gets done: testing, packaging, CS, FB, PMD.

In my root POM I have added following:

<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>com.atlassian.maven.plugins</groupId>
<artifactId>maven-clover2-plugin</artifactId>
<version>3.1.0</version>
<dependencies>
<dependency>
<groupId>com.jnj.gtsc.framework6</groupId>
<artifactId>framework6-buildtools</artifactId>
<version>${fw6.version}</version>
</dependency>
</dependencies>
<configuration>
<licenseLocation>config/java/clover.lic</licenseLocation>
<targetPercentage>50%</targetPercentage>
</configuration>
<executions>
<execution>
<phase>verify</phase>
<goals>
<goal>setup</goal>
<goal>check</goal>
<goal>clover</goal>
</goals>
</execution>
</executions>
</plugin>

In one of the modules I have added this:
<build>
<plugins>
<plugin>
<groupId>com.atlassian.maven.plugins</groupId>
<artifactId>maven-clover2-plugin</artifactId>
</plugin>

When I run 'mvn clean install, the build fails with following error:

[INFO] --- maven-clover2-plugin:3.1.0:setup (default) @ filebrowser-services ---
[INFO] Clover Version 3.1.0, built on May 31 2011 (build-821)
[INFO] Loaded from: c:\repo\com\cenqua\clover\clover\3.1.0\clover-3.1.0.jar
[INFO] Clover: Commercial License registered to Janssen Pharmaceutica NV Beerse.
[INFO] Creating new database at 'C:\dvl\java\gtsc\services\filebrowser\filebrowser-services\target\clover\clover.db'.
[INFO] Processing files at 1.6 source level.
[INFO] Clover all over. Instrumented 23 files (5 packages).
[INFO] Elapsed time = 0.413 secs. (55.69 files/sec, 5,193.705 srclines/sec)
[INFO] Clover Version 3.1.0, built on May 31 2011 (build-821)
[INFO] Loaded from: c:\repo\com\cenqua\clover\clover\3.1.0\clover-3.1.0.jar
[INFO] Clover: Commercial License registered to Janssen Pharmaceutica NV Beerse.
[INFO] Updating existing database at 'C:\dvl\java\gtsc\services\filebrowser\filebrowser-services\target\clover\clover.db'.
[INFO] Processing files at 1.6 source level.
[INFO] Clover all over. Instrumented 16 files (6 packages).
[INFO] 67 test methods detected.
[INFO] Elapsed time = 0.264 secs. (60.606 files/sec, 8,071.97 srclines/sec)
[WARNING] Using [com.jnj.gtsc.services.filebrowser:filebrowser-config:jar:1.0.0-SNAPSHOT], built on Wed Jun 29 17:43:47 CEST 2011 even though a Clover
ed version exists but it's older (lastModified: Wed Jun 29 16:21:50 CEST 2011 ) and could fail the build. Please consider running Clover again on that
dependency's project.
[INFO]
[INFO] --- maven-clover2-plugin:3.1.0:check (default) @ filebrowser-services ---
[INFO] Checking for coverage of [50%] for database [C:\dvl\java\gtsc\services\filebrowser\filebrowser-services\target/clover/clover.db]
[INFO] Clover Version 3.1.0, built on May 31 2011 (build-821)
[INFO] Loaded from: c:\repo\com\cenqua\clover\clover\3.1.0\clover-3.1.0.jar
[INFO] Clover: Commercial License registered to Janssen Pharmaceutica NV Beerse.
[INFO] Coverage check FAILED
[ERROR] The following coverage targets for null were not met:
Total coverage of 0% did not meet target of 50%
[ERROR] Total coverage of 0% did not meet target of 50%

Whst am I doing wrong?

2 answers

1 accepted

0 votes
Answer accepted

Got it working! Running `mvn clean install` does it all.

<execution>
<phase>verify</phase>
<goals>
<goal>instrument-test</goal>
<goal>check</goal>
</goals>
</execution>

Using `instrument-test` prevents CS, PMD, CPD and FB being run on the instrumented code. The only drawback is that it will run the tests twice.

What is the result if you run the clover command from the commandline instead if binded to an maven lifecycle?

mvn clover2:setup test clover2:aggregate clover2:clover

My first feeling is that the phases a not run in the correct order. You first have to instrument your code (generate-sources phase) then run your unittests and then aggregate and create the report.

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Published in Jira

Jira Cloud Performance Improvements

Hello everyone, I am a product manager in the Jira Cloud team focused on making sure our customers have a delightful experience using our products. Towards that goal, one of the areas which is extr...

146 views 1 8
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you