Advanced 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 : */generated/,*/*Bean.java |
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 |
Manage SCM branches
It is possible to run the Sonar maven plugin on a branch.
option |
branch |
usage |
|
from pom.xml |
|
since version |
1.3 |
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 |
|
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 |
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 |
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 extensions
It is possible to define an absolute path for 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 extensions JARs are updated. The directory contains subdirectories like checkstyle/ and pmd/
Example

