Skip to content
This repository has been archived by the owner on Jan 30, 2023. It is now read-only.

Scoverage Sensor not honouring property sonar.projectBaseDir #14

Open
gheo21 opened this issue Aug 30, 2018 · 5 comments
Open

Scoverage Sensor not honouring property sonar.projectBaseDir #14

gheo21 opened this issue Aug 30, 2018 · 5 comments

Comments

@gheo21
Copy link

gheo21 commented Aug 30, 2018

Hello everybody,

I want to use sbt sonar for analyzing projects. However, the plugin is not able to pick up the scoverage information and display it in sonar for my sbt project. There is one caveat, I have a multi module build and all of my modules are in a subfolder called modules. (Please find attached sample project which is reproducing the error https://github.com/mwz/sbt-sonar/files/2335828/multi-module-new.zip)

I essentially changed the sample project from here 47126c4 and moved all the submodules in the submodule folder.

I'm running the sonnar scanner

sbt -Dsonar.host.url=http://localhost:80 -Dsonar.projectBaseDir=modules -Dsonar.sources=src/main/scala  -Dsonar.scoverage.reportPath=target/scala-2.12/scoverage-report/scoverage.xml  clean coverage test coverageReport sonarScan

Not producing any coverage information in sonar, just producing the warning:

WARN: [scoverage] The property: 'sonar.scoverage.reportPath' is deprecated, use the new property 'sonar.scala.scoverage.reportPath' instead.
[info] INFO: [scoverage] Loading the scoverage report file: 'modules/module1/target/scala-2.12/scoverage-report/scoverage.xml'.
[info] INFO: [scoverage] Successfully loaded the scoverage report file.
WARN: [scoverage] The file 'module1/src/main/scala/Example1.scala' has no scoverage information associated with it. 

Running it on the subproject does not make any difference:

sbt -Dsonar.host.url=http://localhost:80 -Dsonar.projectBaseDir=modules -Dsonar.sources=src/main/scala  -Dsonar.modules=module1 -Dsonar.scoverage.reportPath=target/scala-2.12/scoverage-report/scoverage.xml "project module1" clean coverage test coverageReport sonarScan

Note:
Using the docker sonar image sonarqube:6.7.5-alpine via docker compose up. (from here https://github.com/mwz/sonar-scala-docker)

@BalmungSan
Copy link

BalmungSan commented Aug 30, 2018

Hello @gheo21, by chance are you running the analysis from a Wiindows machine ?

@gheo21
Copy link
Author

gheo21 commented Aug 30, 2018

Hello,

@BalmungSan no, it 's a macOs. I've already checked the other items related to the test coverage not being shown, but I couldn't find a fix it.

Thanks!

@mwz
Copy link
Member

mwz commented Sep 2, 2018

Thanks for reporting this issue @gheo21. It is interesting and before I do any digging I was wondering if you had a chance to check the following:

  • does this only affect the Scoverage sensor or Scalastyle and/or Scapegoat too?
  • are you seeing the same behaviour when executing the analysis using the bare sonar-scanner?

Just as a sidenote, from my understanding of how the projectBaseDir property works, if you set it sonar will no longer run analysis on your aggregate project, but I can be wrong about this.

@gheo21
Copy link
Author

gheo21 commented Sep 3, 2018

Hello @mwz,

Thanks for getting back to me.

  1. It looks like the other plugins are not affected by this.
  2. It works if I execute the sonnar-scanner, though not using the projectBaseDir
unzip multi-module-new.zip
cd multi-module-new/modules
$SONAR_SCANNER_HOME/bin/sonar-scanner -Dsonar.modules=module1,module2 -Dsonar.host.url=http://localhost:80 -Dsonar.projectKey=module1 -Dmodule1.sonar.sources=src/main/scala -Dmodule2.sonar.sources=src/main/scala -Dsonar.scala.scoverage.reportPath=target/scala-2.12/scoverage-report/scoverage.xml

So as an intermediate solution I will go with option two, but I think this should work with the sonar scanner sbt plugin.

Best regards!

@mwz
Copy link
Member

mwz commented Sep 3, 2018

Ok, if other plugins are not affected by this, then it's probably got something to do with the way sonar-scala matches paths in the Scoverage reports. I'll have a look into this when I get a minute.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants