Maven +Openclover generate aggrigate test report for multi-module project
Asked by directfn_devops:

Dears,

Parent.pom  
module1.pom  
target/clover/module1Clover.db  
module2.pom  
target/clover/module2Clover.db  
module3.pom  
target/clover/module3Clover.db  
plkModule

<br />

I want to merge all 3 modules clover dbs in to one db in PlkModule and have a report(test coverage report) ,  
How to do this? Could you please advice?

Regards

Raveendra


Answers:
author: Richard White _TechTime_
body: Hi Raveendra,

We do this in a couple of our projects and it is not too tricky.

The aggregate goal will merge all of the moduleXClover.DB into a single db and then you can use the clover task to generate the report.

For example, if running locally, and you have the open-clover plugin specified in your pom.xml you can run:

    mvn clover:setup test clover:aggregate clover:clover

The final "clover:clover" instruction will generage a report based on the merged database, which I think is the second part of your question.

Once it is working locally you can incorporate it in your bamboo build by exposing the report as an artifact and selecting "I already integrated a code coverage tool in this job." and putting in the path to the report.

comments: author: directfn_devops
body: Dear Richard

Thank you very much for your answer..!!!

Now I am getting "

'has 2 candidates, please provide a classifier.'

for one of a module.. Please advice.

"

Could you please advice , when giving maven goals as pom configuration, I am providing goals in my pom as "instrument,aggregate,clover,"

Please find below pom file...

\<plugin\>  
\<groupId\>com.atlassian.maven.plugins\</groupId\>  
\<artifactId\>clover-maven-plugin\</artifactId\>

\<configuration\>

\</configuration\>  
\<executions\>  
\<execution\>  
\<phase\>install\</phase\>  
\<!--\<phase\>pre-site\</phase\>--\>  
\<goals\>  
\<goal\>instrument\</goal\>  
\<goal\>aggregate\</goal\>  
\<goal\>clover\</goal\>  
\</goals\>  
\</execution\>  
\</executions\>  
\</plugin\>

Regards

Raveendra


author: Richard White _TechTime_
body: Hi Raveendra,

Unfortunately that's not an error I have seen before, and other than suggesting you use the newer [open clover clover-maven-plugin,](https://openclover.org/doc/manual/4.2.0/maven--basic-usage.html) I'm not sure what could be wrong with that configuration.


author: directfn_devops
body: Thanks Richard for your reply!!.I was able to generate coverage which is not much accurate form the below pom.

<br />

**\<plugin\>** **\<groupId\>org.openclover\</groupId\>** **\<artifactId\>clover-maven-plugin\</artifactId\>** **\<version\>4.4.1\</version\>** **\<configuration\>** **\<flushPolicy\>threaded\</flushPolicy\>** **\<flushInterval\>30000\</flushInterval\>** **\<!--\<includesTestSourceRoots\>false\</includesTestSourceRoots\>--\>** **\</configuration\>** **\<executions\>** **\<execution\>** **\<phase\>install\</phase\>** **\<!--\<phase\>pre-site\</phase\>--\>** **\<goals\>** **\<!--\<goal\>clean\</goal\>--\>** **\<goal\>instrument-test\</goal\>** **\<goal\>aggregate\</goal\>** **\<goal\>clover\</goal\>** **\</goals\>** **\</execution\>** **\</executions\>** **\</plugin\>**  

But After I added exclusions Coverage become zero.Please find below pom after adding excludes. Could you please advice?

<br />

**\<plugin\>** **\<groupId\>org.openclover\</groupId\>** **\<artifactId\>clover-maven-plugin\</artifactId\>** **\<version\>4.4.1\</version\>** **\<configuration\>** **\<excludes\>** **\<exclude\>\*\*/\*_InternalTmp.java\</exclude\>** **\</excludes\>** **\<flushPolicy\>threaded\</flushPolicy\>** **\<flushInterval\>30000\</flushInterval\>** **\<!--\<includesTestSourceRoots\>false\</includesTestSourceRoots\>--\>** **\</configuration\>** **\<executions\>** **\<execution\>** **\<phase\>install\</phase\>** **\<!--\<phase\>pre-site\</phase\>--\>** **\<goals\>** **\<!--\<goal\>clean\</goal\>--\>** **\<goal\>instrument-test\</goal\>** **\<goal\>aggregate\</goal\>** **\<goal\>clover\</goal\>** **\</goals\>** **\</execution\>** **\</executions\>** **\</plugin\>**  
Regards

Raveendra


author: Richard White _TechTime_
body: Hi again Raveendra,

I personally I would try the goals

- clean

- instrument (not instrument-test)

- aggregate

- clover

For testing I would remove the flush policy and flushInterval and just use the default settings. I am assuming you are just doing coverage for unit tests via surefire at the moment, not trying to get coverage for integration or functional tests?