org.gradle.sonar.runner

## Class SonarRunnerExtension

- java.lang.Object
- - org.gradle.sonar.runner.SonarRunnerExtension

- Direct Known Subclasses:
    SonarRunnerRootExtension

      @Incubating
      public class SonarRunnerExtension
      extends Object

  An extension for configuring the Sonar Runner integration.

  The extension is added to all projects that have the `"sonar-runner"` plugin applied, and all of their subprojects. The extension of the project that actually applies the `"sonar-runner"` plugin is a subclass of this type, `SonarRunnerRootExtension`, which also allows configuration of the Sonar Runner process.

  Example usage:

       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 }
         }
       }

  ### Sonar Properties

  The Sonar configuration is provided by using the `sonarProperties(org.gradle.api.Action)` method and specifying properties. Certain properties are required, such as `"sonar.host.url"` which provides the address of the Sonar server. For details on what properties are available, see Analysis Parameters in the Sonar documentation.

  The `"sonar-runner"` plugin adds default values for several plugins dependening on the nature of the project. Please see the “Sonar Runner Plugin” chapter of the Gradle User Guide for details on which properties are set and their values.

  Please see the `SonarProperties` class for more information on the mechanics of setting Sonar properties, including laziness and property types.

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static String` | `SONAR_RUNNER_CONFIGURATION_NAME`
    `static String` | `SONAR_RUNNER_EXTENSION_NAME`
    `static String` | `SONAR_RUNNER_TASK_NAME`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `SonarRunnerExtension(org.gradle.listener.ActionBroadcast<SonarProperties> propertiesActions)`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `boolean` | `isSkipProject()` If the project should be excluded from analysis.
    `void` | `setSkipProject(boolean skipProject)`
    `void` | `sonarProperties(Action<? super SonarProperties> action)` Adds an action that configures Sonar properties for the associated Gradle project.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### SONAR_RUNNER_CONFIGURATION_NAME

          public static final String SONAR_RUNNER_CONFIGURATION_NAME

      See Also:
        Constant Field Values

    - #### SONAR_RUNNER_EXTENSION_NAME

          public static final String SONAR_RUNNER_EXTENSION_NAME

      See Also:
        Constant Field Values

    - #### SONAR_RUNNER_TASK_NAME

          public static final String SONAR_RUNNER_TASK_NAME

      See Also:
        Constant Field Values

  - ### Constructor Detail

    - #### SonarRunnerExtension

          public SonarRunnerExtension(org.gradle.listener.ActionBroadcast<SonarProperties> propertiesActions)

  - ### Method Detail

    - #### sonarProperties

          public void sonarProperties(Action<? super SonarProperties> action)

      Adds an action that configures Sonar properties for the associated Gradle project.

      Global Sonar properties (e.g. database connection settings) have to be set on the "root" project of the Sonar run. This is the project that has the `sonar-runner` plugin applied.

      The action is passed an instance of `SonarProperties`. Evaluation of the action is deferred until `sonarRunner.sonarProperties` is requested. Hence it is safe to reference other Gradle model properties from inside the action.

      Sonar properties can also be set via system properties (and therefore from the command line). This is mainly useful for global Sonar properties like database credentials. Every system property starting with `"sonar."` is automatically set on the "root" project of the Sonar run (i.e. the project that has the `sonar-runner` plugin applied). System properties take precedence over properties declared in build scripts.

      Parameters:
        `action` - an action that configures Sonar properties for the associated Gradle project

    - #### isSkipProject

          public boolean isSkipProject()

      If the project should be excluded from analysis.

      Defaults to `false`.

    - #### setSkipProject

          public void setSkipProject(boolean skipProject)