To activate the connection between Gradle and SonarQube it is necessary to add some information to the file "build.gradle", and namely:


Using the plugins DSL:


plugins {

  id "org.sonarqube" version "3.0"

}


Or, using legacy plugin application:


buildscript {

  repositories {

    maven {

      url "https://plugins.gradle.org/m2/"

    }

  }

  dependencies {

    classpath "org.sonarsource.scanner.gradle:sonarqube-gradle-plugin:3.0"

  }

}


apply plugin: "org.sonarqube"


Specific connection configuration parameters can be added to the "gradle.properties" file, e.g.:


# gradle.properties

systemProp.sonar.host.url=http://localhost:9000

 

#----- Token generated from an account with 'publish analysis' permission

systemProp.sonar.login=<token>


It is recommended to use the legacy style.


The example project "IocGradle" already contains properly written configuration files.