When building a not multi module project with maven the configuration sonar.projectBaseDir is ignored and the build direcory is always taken as project base dir. It works correctly with multi module projects.
This is a problem for example using lcov, because the paths of the lcov file are always expected to be from the sonar.projectBaseDir.
[code]
[INFO] 19:46:56.340 Analysing [/mnt/jenkins/workspace/nightly/target/coverage/lcov.info]
[WARNING] 19:46:56.347 Could not resolve 309 file paths in [/mnt/jenkins/workspace/nightly/target/coverage/lcov.info], first unresolved path: app/resolver.js
I fail to understand your issue. If your project is not a multi module project, then you have a single pom.xml at the root of your project. And I guess you run mvn sonar:sonar in the same directory? Why would you like to change the value of sonar.projectBaseDir?
Your reproducer is a multi-module project, but you say that the issue is with simple projects, some Iām a bit lost.
Why would you like to change the value of sonar.projectBaseDir ?
Because it is necessary for the code coverage with lcov if the sources of JavaScript are not in the root folder of the project. Example: You put your sources to the folder src/main/ember. In the generated lcov file the paths are relative to src/main/ember. Sonar is only able to process the file correctly, if the sonar.projectBaseDir is set to src/main/ember
Your reproducer is a multi-module project, but you say that the issue is with simple projects, some Iām a bit lost.
If you start the build of the project in the root of the testcase you have a multi module project, if you start the build in the sub folder, you have a non-multi-module project.
C:\projects\tmp>mvn sonar:sonar
[INFO] Project key: test:parent
[INFO] Project base dir: C:\projects\tmp
[INFO] ------------- Scan test
[INFO] Base dir: C:\projects\tmp\sub\src\main\ember
[INFO] Working dir: C:\projects\tmp\sub\target\sonar
[INFO] Source paths: C:\projects\tmp\sub\pom.xml
C:\projects\tmp\sub>mvn sonar:sonar
[INFO] Project key: test:test
[INFO] Project base dir: C:\projects\tmp\sub
[INFO] ------------- Scan test
[INFO] Base dir: C:\projects\tmp\sub
[INFO] Working dir: C:\projects\tmp\sub\target\sonar
To me the issue should be fixed in our lcov importer, but Iām waiting for opinion of my colleagues on this. Changing the project baseDir ājustā for the coverage is a mistake in my opinion, and may have many other side effects.
Indeed our LCOV parser expects either an absolute path or a relative to the project base directory. When paths in your LCOV file are relative to something else, how LCOV parser can know what is this āsomething elseā?
I would suggest you two things:
see if your coverage tool can generate report with absolute paths
write a small script which will prefix all paths in your report with appropriate path (e.g. src/main/ember in your example), and run it before running analysis.
The parser could provide a property to configure that like suggested by Julien
I think you misinterpret what Julien said, he only pointed that this problem should be fixed in the context of lcov importer.
The sonar-maven-plugin could be fixed to honor the configuration of sonar.projectBaseDir like suggested by me in this thread
I think you are missing the fact that base dir of project not only used to resolve relative paths in LCOV report but also to define base dir of the project:) So I expect that changing it to your JS dir will force analysis to ignore other files in your module.
Iāve created a ticket on SonarJS analyser. In meantime you can use one of ideas Iāve suggested to workaround your problem.