Reputation: 1417
I've searched through several questions related to multi-module maven projects and sonar, but those were mostly about aggregating code coverage metrics.
I have a multi-module maven project being analyzed by sonar.
If I run the analysis straight from the terminal using mvn sonar:sonar
the resulting analysis will display the dependencies between the maven modules in the Design page.
However, if I run the analysis by invoking sonar-runner via Jenkins the resulting analysis will have missed the dependencies between the maven modules.
Here's a snippet of the top-level pom where I set sonar parameters:
<profile>
<id>sonar</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<properties>
<sonar.jdbc.url>
jdbc:mysql://myhost:3306/sonar?useUnicode=true&characterEncoding=utf8
</sonar.jdbc.url>
<sonar.jdbc.username>sonar</sonar.jdbc.username>
<sonar.jdbc.password>sonar</sonar.jdbc.password>
<sonar.host.url>http://myhost:9999</sonar.host.url>
<sonar.java.source>1.7</sonar.java.source>
<sonar.login>jenkins</sonar.login>
<sonar.password>jenkins</sonar.password>
</properties>
</profile>
On Jenkins I configured the job to do a clean install -DskipTests=true
in the build step followed by a post-build action to run Sonar.
I'm using Maven version 3.0.5, SonarQube version 3.7, Sonar Runner 2.3 and Java 1.7.0_45.
Any idea of what can I be missing in my configuration?
Upvotes: 1
Views: 2252
Reputation: 2850
Indeed the SonarQube Maven bootstrapper relies on Maven to get the dependencies (either on modules or on external libraries). But SonarRunner doesn't have access to such kind of information and that's why when you analyse a project with SonarRunner you don't get any information about external dependencies.
Upvotes: 1
Reputation: 6530
Ok if you are using Jenkins, you need to install Sonar Plugin and set parameters. Then, you need to create a job and run maven target:
clean install
After that, mark Sonar checkbok. Run your job and you should see your code coverage.
PS: If you are using module you must have pom-root with all your modules.
Upvotes: 0