This task runs SonarQube Scanner, a tool for code analysis and continuous inspection.
Table C.98: Attributes
Name | Type | Description | Default | Required |
---|---|---|---|---|
executable | String | Fully-qualified path of SonarQube Scanner executable. If executable is in PATH environment variable, the executable name is sufficient. | n/a | Yes |
configuration | String | Path of configuration file. The file format is that of a properties file (as used by Java), i.e. a list of key-value pairs <key>=<value> . | n/a | No |
errors | String | Sets errors flag of SonarQube Scanner. Allowed values are "true ", "false ", "yes ", "no ", "1 ", and "0 ". | false | No |
debug | String | Sets debug flag of SonarQube Scanner. Allowed values are "true ", "false ", "yes ", "no ", "1 ", and "0 ". | false | No |
This example assumes that the SonarQube Scanner is called sonarqube-scanner and is available on the PATH.
<?xml version="1.0" encoding="UTF-8"?> <project name="sonar-minimal-example" default="sonar"> <sonar executable="sonarqube-scanner"> <property name="sonar.projectKey" value="my-unique-project-key" /> <property name="sonar.projectName" value="Foo Project" /> <property name="sonar.projectVersion" value="0.1.0" /> <property name="sonar.sources" value="src" /> </sonar> </project>
This example consists of two files – build.xml and sonar-project.properties.
The build.xml:
<?xml version="1.0" encoding="UTF-8"?> <project name="sonar-full-example" default="sonar"> <sonar executable="path/to/sonarqube-scanner" errors="true" debug="true" configuration="path/to/sonar-project.properties" > <!-- Assume that mandatory SonarQube parameters are defined in configuration file! --> <property name="sonar.log.level" value="DEBUG" /> </sonar> </project>
The configuration file path/to/sonar-project.properties:
sonar.projectKey = my-unique-project-key sonar.projectName = Foo Project sonar.projectVersion = 0.1.0 sonar.sources = src
property
Analysis parameters of SonarQube Scanner can be defined in a configuration file or via nested property
elements. If both a configuration file and property elements are provided, the properties are merged. Values from property
elements overwrite values from the configuration file if their property keys are equal.
Table C.99: Attributes
Name | Type | Description | Default | Required |
---|---|---|---|---|
name | String | Name of property. | n/a | Yes |
value | String | Value of property. | n/a | Yes |