sonar.coverage.exclusions not working when added from the gradle plugin

6,507 views
Skip to first unread message

davidmar...@gmail.com

unread,
Jun 27, 2017, 2:50:38 AM6/27/17
to SonarQube
Hi guys!

After updating from Sonar 6.2 to Sonar 6.4 the coverage exclusions are not working anymore in my project. I am using the version 2.5 of the gradle plugin and in the sonar scanner context, i can see the property, so it looks like sonarqube is not honoring it.

If I set the property in the sonarqube web it does work. Any ideas about how can I investigate this issue? or workaround it?

Regards

Julien HENRY

unread,
Jun 27, 2017, 2:58:15 AM6/27/17
to SonarQube, davidmar...@gmail.com
Hi David,

We need a bit more details to investigate. How do you set the property? Can you share scanner logs with verbose output?

++

Julien

davidmar...@gmail.com

unread,
Jun 27, 2017, 4:38:02 AM6/27/17
to SonarQube, davidmar...@gmail.com
Hi Julien,

I set the property in gradle. By the scanner logs you mean the gradle or the log in the background task?


Snippet setting the property:

property "sonar.coverage.exclusions", exclusionList.join(", ")


In the scanner context log I can see the expected list. Please note adding the space did not make a difference, i added it just in case.

Settings for module: WhAndroid_MODULES:push
  - sonar.binaries=/Users/jenkins/Home/workspace/WhModules-android/push/build/intermediates/classes/debug
  - sonar.coverage.exclusions=**/R.*, **/R$*.*, **/*$ViewInjector*.*, **/BuildConfig.*, **/Manifest*.*, android/**/*.*, **/*Injector.*, **/model/**, **/*Exception.*
  - sonar.cpd.exclusions=**/model/**

Regards

davidmar...@gmail.com

unread,
Jul 3, 2017, 5:48:25 AM7/3/17
to SonarQube, davidmar...@gmail.com
Hi Julien,

Any news on this? I can try to give you more info if you need it

Regards

Julien HENRY

unread,
Jul 7, 2017, 1:43:07 PM7/7/17
to SonarQube, davidmar...@gmail.com
Hi David,

Could you please enable Gradle info logs (--info) and check that you see the following log for the subprojects where you expect coverage to be excluded:
"Excluded sources for coverage: XXXX"

++

davidmar...@gmail.com

unread,
Jul 10, 2017, 2:31:27 AM7/10/17
to SonarQube, davidmar...@gmail.com
Sure,

Here you go:

-------------  Scan config
Defining extension
Excluded sources for coverage: 
  **/activities/**
  **/R.*
  **/R$*.*
  **/*$ViewInjector*.*
  **/BuildConfig.*
  **/Manifest*.*
  android/**/*.*
  **/*Injector.*
  **/model/**
  **/*Exception.*
Initializer GenericCoverageSensor
Initializer GenericCoverageSensor (done) | time=0ms

This is a multimodule project so I have many similar blocks (one per project)

Thanks

davidmar...@gmail.com

unread,
Jul 10, 2017, 11:20:04 AM7/10/17
to SonarQube, davidmar...@gmail.com
Hi Julien,

As I have some similar rules on the web, I would put another example from a different module.

Excluded sources for coverage: 
  **/factory/MediaSourceFactory.*
  **/player/SimpleExoPlayerWrapper.*
  **/R.*
  **/R$*.*
  **/*$ViewInjector*.*
  **/BuildConfig.*
  **/Manifest*.*
  android/**/*.*
  **/*Injector.*
  **/model/**
  **/*Exception.*


And in the backend, I am getting this line:
Regards

amit1...@gmail.com

unread,
Oct 13, 2017, 2:34:50 PM10/13/17
to SonarQube
try putting the exclusions in the same line, it fixed the issue for us.
Reply all
Reply to author
Forward
0 new messages