Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 36 Next »

Advanced Maven parameters

There are extra parameters that can be used when running the Sonar maven plugin.

Hide sources

Sometimes, for security or other reasons, project sources must not be published.

option

sonar.importSources

usage

from pom.xml

version

since 1.5

Inject historical data

When using Sonar, it becomes quickly necessary to input historical data and to highlight some events. It is possible by going for example in a tag and use the sonar.projectDate option. By default, the version name to be used is the one in the pom.xml, but it is possible to override it using the sonar.projectVersion option.

option

sonar.projectDate & sonar.projectVersion

usage

from pom.xml

N/A

version

since 1.5

Exclude resources

The resources (classes/packages) to exclude from analysis are configured online in the project settings page. This configuration can also be set maven-side :

option

sonar.exclusions

value

comma-separated list of wildcard patterns. Example : com/mycompany/*/.java,**/*Dummy.java

from pom.xml

version

since 1.8


Exclude modules

Some project modules should not be analyzed and consolidated with global project measures, for instance samples, integration tests or generated code.

option

sonar.skippedModules

usage

from pom.xml

N/A

since version

1.5

Include modules

List the full list of modules to analyse, all others modules are automatically ignored. Be careful : the root project must be added to the list.

option

sonar.includedModules

usage

from pom.xml

N/A

since version

2.2

Manage SCM branches

It is possible to run the Sonar maven plugin on a branch.

option

branch

usage

from pom.xml

since version

branch since 1.3, sonar.branch since 1.10

Define the quality profile to be used

Through the Sonar web interface, you can define as many quality profiles as you want and you can easily associate one of this quality profile to a given project. You can also make this association by using the property "sonar.profile". The value of this property overload any configuration made in the Sonar web interface.

option

sonar.profile

usage

from pom.xml

version

since 1.6

Dynamic analysis

Dynamic analysis relates to unit tests execution. By default, those unit tests are executed but you can optionally decide to do only static analysis or to reuse existing unit tests reports.

option

sonar.dynamicAnalysis

values

  • true (default)
  • false. Replace the deprecated parameter 'sonar.light=true' for non-maven projects.
  • reuseReports : reuse XML files found on disk

usage

from pom.xml

version

since 1.7

option

sonar.surefire.reportsPath

values

the absolute or relative path of the surfire reports directory

usage

from pom.xml

version

since 1.7

option

sonar.cobertura.reportPath

values

the absolute or relative path of the cobertura xml report file

usage

from pom.xml

version

since 1.7

option

sonar.clover.reportPath

values

the absolute or relative path of the clover xml report file

usage

from pom.xml

version

since 1.7

Run maven phase or goal prior to analysis

When Sonar need a phase or maven goal to be executed prior to analysis, this parameter can be used. A good example is generate-sources.

option

sonar.phase

usage

from pom.xml

<sonar.phase>generate-sources</sonar.phase>

version

since 1.10

Skip install phase

In order for Sonar to run properly, the program must be compiled at some point. Until v. 1.4, the Sonar maven plugin was running an install goal by default. This phase can be skipped, for example for performance reasons.

Deprecated since Sonar 1.5 : the install phase is not executed anymore.

option

sonar.skipInstall

usage

from pom.xml

N/A

version

before 1.5

Increasing HTTP timeouts of requests to Sonar server

The Maven plugin executes some HTTP requests to the Sonar server. Two timeouts makes the call fail if the server connection is too slow. In such a case the timeouts can be increased from Maven properties.

options

sonar.host.connectTimeoutMs and sonar.host.readTimeoutMs

default values

respectively 30'000 and 60'000 milliseconds

version

since 1.12

Deactivating bytecode analysis

Since Sonar 2.0, the java bytecode is analyzed by Sonar in order to extract dependencies between packages and files. Those dependencies are used for instance to display the DSM (Dependency System Matrix). This bytecode analysis can be deactivated.

option

sonar.skipDesign

usage

from pom.xml

version

since 2.O

Using environment variables

It is possible since v 1.5 to use environment variables in the sonar.properties file.

To use an environment variable, use the following syntax : ${env:NAME_OF_ENV_VARIABLE}.

For example :

Setting absolute path for rule extensions

It is possible to define an absolute path for rule extensions in the sonar.properties file. This parameter is useful when Sonar is deployed as a WAR. It avoids from packaging the WAR file each time rule extensions JARs are updated. The directory must contains subdirectories like checkstyle/ and pmd/

Example

Specifying the language of the source code

By default, Sonar is using Java source code analysers. If a Sonar plugin allows to analyse another given language, the associated source code analysers can be activated with the property 'sonar.language'.

option

sonar.language

usage

from pom.xml

version

since 2.0

  • No labels