Class SonarExtension
- java.lang.Object
-
- org.sonarqube.gradle.SonarExtension
-
public class SonarExtension extends java.lang.ObjectAn extension for configuring the Sonar analysis.The extension is added to all projects that have the
"sonar-gradle"plugin applied, and all of their subprojects.Example usage:
sonar { skipProject = false // this is the default properties { 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
properties(org.gradle.api.Action)method and specifying properties. Certain properties are required, such as"sonar.host.url"which provides the address of the server. For details on what properties are available, see Analysis Parameters in the SonarQube documentation.The
"sonar-gradle"plugin adds default values for several plugins depending on the nature of the project. Please see the SonarScanner for Gradle documentation for details on which properties are set and their values.Please see the
SonarPropertiesclass for more information on the mechanics of setting Sonar properties, including laziness and property types.
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.StringSONAR_DEPRECATED_EXTENSION_NAMEstatic java.lang.StringSONAR_DEPRECATED_TASK_NAMEstatic java.lang.StringSONAR_EXTENSION_NAMEstatic java.lang.StringSONAR_TASK_NAME
-
Constructor Summary
Constructors Constructor Description SonarExtension(ActionBroadcast<SonarProperties> propertiesActions)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.StringgetAndroidVariant()booleanisSkipProject()Defaults tofalse.voidproperties(org.gradle.api.Action<? super SonarProperties> action)Adds an action that configures SonarQube properties for the associated Gradle project.voidsetAndroidVariant(java.lang.String androidVariant)voidsetSkipProject(boolean skipProject)
-
-
-
Field Detail
-
SONAR_EXTENSION_NAME
public static final java.lang.String SONAR_EXTENSION_NAME
- See Also:
- Constant Field Values
-
SONAR_DEPRECATED_EXTENSION_NAME
public static final java.lang.String SONAR_DEPRECATED_EXTENSION_NAME
- See Also:
- Constant Field Values
-
SONAR_TASK_NAME
public static final java.lang.String SONAR_TASK_NAME
- See Also:
- Constant Field Values
-
SONAR_DEPRECATED_TASK_NAME
public static final java.lang.String SONAR_DEPRECATED_TASK_NAME
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
SonarExtension
public SonarExtension(ActionBroadcast<SonarProperties> propertiesActions)
-
-
Method Detail
-
properties
public void properties(org.gradle.api.Action<? super SonarProperties> action)
Adds an action that configures SonarQube properties for the associated Gradle project.Global SonarQube properties (e.g. server connection settings) have to be set on the "root" project of the SonarQube run. This is the project that has the
sonar-gradleplugin applied.The action is passed an instance of
SonarQubeProperties. Evaluation of the action is deferred untilsonarqube.propertiesis requested. Hence it is safe to reference other Gradle model properties from inside the action.SonarQube properties can also be set via system properties (and therefore from the command line). This is mainly useful for global SonarQube properties like database credentials. Every system property starting with
"sonar."is automatically set on the "root" project of the SonarQube run (i.e. the project that has thesonar-gradleplugin applied). System properties take precedence over properties declared in build scripts.- Parameters:
action- an action that configures SonarQube properties for the associated Gradle project
-
isSkipProject
public boolean isSkipProject()
Defaults tofalse.- Returns:
- true if the project should be excluded from analysis.
-
setSkipProject
public void setSkipProject(boolean skipProject)
-
getAndroidVariant
@CheckForNull public java.lang.String getAndroidVariant()
- Returns:
- Name of the variant to analyze. If null we'll take the first release variant
-
setAndroidVariant
public void setAndroidVariant(java.lang.String androidVariant)
-
-