SonarProject (Gradle API 2.9)
Date: 2015-11-17

Package: org.gradle.api.plugins.sonar.model

## [Groovy] Class SonarProject

- org.gradle.api.plugins.sonar.model.SonarProject

- Per-project configuration options.

  deprecated:
    The 'sonar' plugin has been superseded by the official plugin from SonarQube, please see: http://docs.sonarqube.org/display/SONAR/Analyzing+with+Gradle

- - ### Properties Summary

    Properties
    Type | Name and description
    --- | ---
    `File` | `baseDir` The base directory for the analysis.
    `List<File>` | `binaryDirs` The directories containing the project's compiled code to be analyzed.
    `File` | `cloverReportPath` The Clover XML report file.
    `File` | `coberturaReportPath` The Cobertura XML report file.
    `String` | `date` The date when analysis was performed.
    `String` | `description` A description for the project.
    `String` | `dynamicAnalysis` Whether and how to perform dynamic analysis.
    `boolean` | `importSources` Tells whether to the project's source code should be stored and made available via the Sonar web interface.
    `SonarJavaSettings` | `java` Java-related configuration options.
    `String` | `key` The identifier for the project.
    `String` | `language` The programming language to be analyzed.
    `FileCollection` | `libraries` A class path containing the libraries used by this project.
    `String` | `name` The name for the project.
    `List<groovy.lang.Closure>` | `propertyProcessors` Post-processors for per-project Sonar properties.
    `boolean` | `skip` Tells whether to skip analysis of this project.
    `boolean` | `skipDesignAnalysis` Tells whether to skip analysis of the project's design.
    `List<File>` | `sourceDirs` The directories containing the project's production source code to be analyzed.
    `String` | `sourceEncoding` The character encoding for the project's source files.
    `String` | `sourceExclusions` Source files to be excluded from analysis.
    `List<File>` | `testDirs` The directories containing the project's test source code to be analyzed.
    `File` | `testReportPath` The directory containing the JUnit XML test report.
    `String` | `version` The version of the project.
    `File` | `workDir` The working directory for the analysis.

  - ### Methods Summary

    Methods
    Type | Name and description
    --- | ---
    `void` | `java(groovy.lang.Closure config)` Configures Java-related configuration options.
    `void` | `withProjectProperties(groovy.lang.Closure block)` Registers a closure for post-processing the per-project Sonar properties covered by `SonarProjectModel`, and for adding further properties not covered by that model.``

  - ### Inherited Methods Summary

    Inherited Methods
    Methods inherited from class | Name
    --- | ---
    `class Object` | `wait, wait, wait, equals, toString, hashCode, getClass, notify, notifyAll`

- - ### Property Detail

    - #### File baseDir

      The base directory for the analysis. Defaults to `$project.projectDir`.

    - #### List<File> binaryDirs

      The directories containing the project's compiled code to be analyzed. Defaults to `main.output.classesDir`.

    - #### @SonarProperty("sonar.clover.reportPath") File cloverReportPath

      The Clover XML report file. Defaults to `null`.

    - #### @SonarProperty("sonar.cobertura.reportPath") File coberturaReportPath

      The Cobertura XML report file. Defaults to `null`.

    - #### @SonarProperty("sonar.projectDate") String date

      The date when analysis was performed. Format is `yyyy-MM-dd` (e.g. `2010-12-25`). Defaults to the current date.

    - #### String description

      A description for the project. Defaults to `$project.description`.

    - #### @SonarProperty("sonar.dynamicAnalysis") String dynamicAnalysis

      Whether and how to perform dynamic analysis. Dynamic analysis includes the analysis of test and code coverage reports. The following values are allowed:

      - `reuseReports`: Test and/or coverage reports will be produced by the Gradle build and passed via `testReportPath`, `coberturaReportPath`, and `cloverReportPath`.
      - `false`: No dynamic analysis will be performed.
      - `true`: Test and/or coverage reports will be produced by Sonar. This mode is not supported by the Gradle Sonar plugin.
      Defaults to `reuseReports`.

    - #### @SonarProperty("sonar.importSources") boolean importSources

      Tells whether to the project's source code should be stored and made available via the Sonar web interface. Defaults to `true`.

    - #### @IncludeProperties SonarJavaSettings java

      Java-related configuration options.

    - #### String key

      The identifier for the project. Defaults to `$project.group:$project.name`.

    - #### @SonarProperty("sonar.language") String language

      The programming language to be analyzed. Only one language per project can be analyzed. Defaults to `java`.

    - #### FileCollection libraries

      A class path containing the libraries used by this project. Defaults to `project.sourceSets.main.compileClasspath + Jvm.current().runtimeJar`.

    - #### String name

      The name for the project. Defaults to `$project.name`.

    - #### List<groovy.lang.Closure> propertyProcessors

      Post-processors for per-project Sonar properties.

      See Also:
        withProjectProperties

    - #### boolean skip

      Tells whether to skip analysis of this project. Allows to only analyze a subset of projects in a Gradle build. Defaults to `false`.

    - #### @SonarProperty("sonar.skipDesign") boolean skipDesignAnalysis

      Tells whether to skip analysis of the project's design. Defaults to `false`.

    - #### List<File> sourceDirs

      The directories containing the project's production source code to be analyzed. Defaults to `project.sourceSets.main.allSource.srcDirs`.

    - #### @SonarProperty("sonar.sourceEncoding") String sourceEncoding

      The character encoding for the project's source files. Accepts the same values as Charset (e.g. `UTF-8`, `MacRoman`, `Shift_JIS`). Defaults to the JVM's platform encoding.``

    - #### @SonarProperty("sonar.exclusions") String sourceExclusions

      Source files to be excluded from analysis. Specified as comma-separated list of Ant-style patterns which are relative to a source directory.

      Example: `com/mycompany/*/.java, **/*Dummy.java`.

      Defaults to `null`.

    - #### List<File> testDirs

      The directories containing the project's test source code to be analyzed. Defaults to `project.sourceSets.test.allSource.srcDirs`.

    - #### @SonarProperty("sonar.surefire.reportsPath") File testReportPath

      The directory containing the JUnit XML test report. Defaults to `project.test.testResultsDir`.

    - #### String version

      The version of the project. Defaults to `$project.version`.

    - #### File workDir

      The working directory for the analysis. Defaults to `$project.buildDir/sonar`.``

  - ### Method Detail

    - #### void java(groovy.lang.Closure config)

      Configures Java-related configuration options. The specified closure delegates to an instance of type SonarJavaSettings.

      Parameters:
        `config` - Java-related configuration options

    - #### void withProjectProperties(groovy.lang.Closure block)

      Registers a closure for post-processing the per-project Sonar properties covered by `SonarProjectModel`, and for adding further properties not covered by that model. The properties are passed to the closure as a map of String keys and values. Keys correspond to the Sonar properties as described in the Sonar documentation.``

      Evaluation of the closure is deferred until build execution time. If this method is called multiple times, closures will be evaluated in the order they have been registered.

      Example:

           withProjectProperties { props ->
               // add further properties
               props["some.sonar.property"] = "some value"
               props["another.sonar.property"] = "another value"

               // modify existing properties (rarely necessary)
               props["sonar.sourceEncoding"] = "UTF-8"
               props.remove("sonar.projectDate")
           }

      Parameters:
        `block` - a closure for post-processing per-project Sonar properties