Thursday, June 9, 2016

Sonar maven-surefire-plugin quirks

I was integrating my maven multi module project with sonar, and ran into some quirky behavior:

1. After some config changes I suddenly started seeing


Error updating database. Cause: java.sql.SQLIntegrityConstraintViolationException: ORA-00001: unique constraint (SONAR.PROJECTS_KEE) violated

The error may involve org.sonar.db.component.ComponentMapper.insert-Inline

The error occurred while setting parameters

Cause: java.sql.SQLIntegrityConstraintViolationException: ORA-00001: unique constraint (SONAR.PROJECTS_KEE) violated

Turns out I was calling mvn sonar:sonar with -Dsonar.exclusions and this exclusion was also set on the sonar server, under Administration > General Settings > Analysis Scope > Files as a source file exclusion.

Apparently excluding the same regex on the server and with the maven argument makes Sonar choke.

You can read the full explanation on my stackoverflow question


2. Some packages did not get code coverage with maven-surefire-plugin. Try as I might I always had 0% coverage on these packages. You can view my set up here. The maven output showed that the tests were run, and surefire did not produce any warnings.

It turned out that maven-surefire-plugin was included as a  plugin in the build section in both the parent pom and the child pom. Hence the surefire plugin ran in the child module, but the resultant coverage, which was taken from the file specified by the sonar.jacoco.reportPath property did have these tests. Makes sense now of course, but it was a tricky bug to find :)

No comments:

Post a Comment