sonar.projectBaseDir doesn't work with non-multi-module projects

javascript
sonarjs

(Bernhard) #1

sonar-maven-plugin:3.4.0.905:sonar

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

[code]


(Bernhard) #2

testcase.zip.txt (1.5 KB)


(Bernhard) #3

Could someone please file this as bug?


(Julien Henry) #5

Hi @bmaehr,

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.

Can you elaborate?


(Bernhard) #6

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

(Bernhard) #8

@Julien_HENRY Any news on this? Should be easy to fix.


(Julien Henry) #9

Hi @bmaehr

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.


(Bernhard) #10

Hi @Julien_HENRY,

You are right that it is only some kind of workaround and the lcov importer should be improved.

I also don’t expect, that the baseDir should be changed generally because of the reasons you mentioned.

But when I explicitly configure the baseDir using the provided property I expect, that my configuration is honored.