Migrating to sonarqube gradle plugin

Sonarqube recently released a gradle sonarqube plugin.  This replaces the sonar runner plugin provided by gradle.

Migrating to the new plugin is fairly straightforward and involves the following changes:
  • Replace
apply plugin: "sonar-runner"


apply plugin: "org.sonarqube"

or using the style of the new plugin mechanism (gradle 2.1 and above)

plugins {
  id "org.sonarqube" version "1.0"

  • Replace
sonarRunner {
    sonarProperties {


sonarqube {
    properties {

  • Move global sonarqube properties to gradle.properties - either in ~/.gradle or in your project base directory.  Use systemProp prefix to indicate system property

#if  authentication enabled

As per documentation,  the plugin uses gradle's object model to provide smart defaults for many of the standard SonarQube properties, specifically

Property - Gradle default
sonar.projectKey - “$project.group:$project.name”
sonar.projectName - project.name
sonar.projectDescription  - project.description
sonar.projectVersion - project.version

Since my gradle script did not have the above gradle defaults set, I specified the sonar properties explicitly in the properties section of the sonarqube plugin configuration. But for some reasons, they were not used and I ended up getting the project folder name as project name and project key with no description and version. The same had worked well with the sonar-runner plugin.
  • Now run
gradlew build sonarqube


gradle build sonarqube

(if not using the gradle wrapper)

You should see sonarqube analysis happening after the build and thereafter browse to the report.


Popular posts from this blog

Opening a safe deposit locker in SBI

Opening a Kannada Word document

When gas leaks