- which versions are you using (SonarQube Server / Community Build, Scanner, Plugin, and any relevant extension)
sonarqube-10.5.1.90531
SonarScanner CLI 6.2.1.4610
- how is SonarQube deployed: zip, Docker, Helm
zip
- what are you trying to achieve
I want to analyze the project that has some files outside of project basedir.
- what have you tried so far to achieve this
Played with different combinations of sonar.baseDir and sonar.sources parameters.
My directory structure is like this:
D:\foobar\common\
D:\foobar\common\helloworld.cpp
D:\foobar\common\something.cpp
D:\foobar\Foo\
D:\foobar\Foo\Foo.sln
D:\foobar\Foo\Bar
D:\foobar\Foo\Bar\Bar.vcxproj
D:\foobar\Foo\Bar\sonar-project.properties
The file helloworld.cpp is added into the Bar project using Visual Studio (Right click ā Add ā Existing itemā¦)
My sonar-project.properties file:
sonar.projectKey=my_example_Bar
sonar.projectName=MY example Bar
sonar.sources=.,D:\\foobar\\common
sonar.cfamily.build-wrapper-output=build-wrapper-output-directory
sonar.projectVersion=1.0
I build the project using this command:
build-wrapper-win-x86-64.exe --outdir D:\foobar\Foo\Bar\build-wrapper-output-directory MSBuild.exe D:\foobar\Foo\Bar\Bar.vcxproj /t:Rebuild /p:Platform=x86 /p:Configuration=Release /nodeReuse:False
Then I execute āsonar-scannerā inside the project directory D:\foobar\Foo\Bar.
In the output I see the message that the helloworld.cpp file will not be analyzed.
File āD:\foobar\common\helloworld.cppā is ignored. It is not located in project basedir āD:\foobar\Foo\Barā.
Why doesnāt sonarqube allow files outside of project base dir?
In my case I really canāt set the baseDir to D:\foobar\common\ because Iām trying to analyze the D:\foobar\Foo\Bar\ project. D:\foobar\common\ directory is not a project at all and these files would be used by multiple projects. So this solution for example does not work for me: Sonar-scanner don't find source files
Is there anything else I can do to analyze this project correctly?