Groovy Documentation

org.gradle.api.sonar.runner
[Groovy] Class SonarRunnerPlugin

java.lang.Object
  org.gradle.api.sonar.runner.SonarRunnerPlugin
All Implemented Interfaces:
Plugin

@Incubating
class SonarRunnerPlugin

A plugin for analyzing projects with the Sonar Runner. When applied to a project, both the project itself and its subprojects will be analyzed (in a single run). Therefore, it's common to apply the plugin only to the root project. To exclude selected subprojects from being analyzed, set sonarRunner.skipProject = true.

The plugin is configured via SonarRunnerExtension. Here is a small example:

 sonarRunner {
     skipProject = false // this is the default

     sonarProperties {
         property "sonar.host.url", "http://my.sonar.server" // adding a single property
         properties mapOfProperties // adding multiple properties at once
         properties["sonar.sources"] += sourceSets.other.java.srcDirs // manipulating an existing property
     }
 }
 
The Sonar Runner already comes with defaults for some of the most important Sonar properties (server URL, database settings, etc.). For details see Analysis Parameters in the Sonar documentation. The sonar-runner plugin provides the following additional defaults:
sonar.projectKey
"$project.group:$project.name"
sonar.projectName
project.name
sonar.projectDescription
project.description
sonar.projectVersion
sonar.version
sonar.projectBaseDir
project.projectDir
sonar.working.directory
"$project.buildDir/sonar"
sonar.dynamicAnalysis
"reuseReports"
For project that have the java-base plugin applied, additionally the following defaults are provided:
sonar.java.source
project.sourceCompatibility
sonar.java.target
project.targetCompatibility
For project that have the java plugin applied, additionally the following defaults are provided:
sonar.sources
sourceSets.main.allSource.srcDirs (filtered to only include existing directories)
sonar.tests
sourceSets.test.allSource.srcDirs (filtered to only include existing directories)
sonar.binaries
sourceSets.main.runtimeClasspath (filtered to only include directories)
sonar.libraries
sourceSets.main.runtimeClasspath (filtering to only include files; rt.jar added if necessary)
sonar.surefire.reportsPath
test.testResultsDir (if the directory exists)


Property Summary
Project targetProject

 
Method Summary
void apply(Project project)

void computeSonarProperties(Project project, Properties properties)

 
Methods inherited from class Object
wait, wait, wait, equals, toString, hashCode, getClass, notify, notifyAll
 

Property Detail

targetProject

Project targetProject


 
Method Detail

apply

void apply(Project project)


computeSonarProperties

void computeSonarProperties(Project project, Properties properties)


 

Gradle API 1.8