I have a multi-module maven project and want to generate code coverage reports for subsets of the project and track the results using sonar.
The project has modules M1
, M2
and M3
and I want to generate coverage reports for package foo/**
and for package bar/**
. The packages may exist in multiple modules.
I'm using cobertura to generate code coverage files in my maven project.
My question is: what is best practice for generating multiple code coverage reports for a single project?
One option is to configure my maven build with a profiles to generate coverage data for specific packages, e.g. coverage-foo
would configure the cobertura maven plugin with <include>foo/**</include>
, and coverage-bar
would configure the cobertura plugin with <include>bar/**</include>
. Then I would configure sonar with two branches of the project: one for foo
and one for bar
, with no configuration on the sonar side.
But another option is to generate code coverage data for the entire projet, and configure each sonar project with appropriate inclusions. So the sonar 'foo' branch would have settings that only the foo/**
files are included, and the sonar bar
branch would have similar settings for the bar
package.
Both seem equivalent to me (in terms of sonar output), and I favour the first option, but I'd like to know if this is the 'best practice' method of generating multiple code coverage 'views' of the same multi-module project. Or if one option has disadvantages that I have not considered.
(Note: there is a commercial 'views' plugin for sonar but I am restricted to free plugins for now)