We have faced this analysis error;
ERROR: Error during SonarScanner execution
java.lang.IllegalStateException: The “build-wrapper-dump.json” file was found but 0 C/C++/Objective-C files were analyzed. Please make sure that:
- you are using the latest version of the build-wrapper and the CFamily analyzer
- you are correctly invoking the scanner with correct configuration
- your compiler is supported
- you are wrapping your build correctly
- you are wrapping a full/clean build
- you are providing the path to the correct build-wrapper output directory
- you are building and analyzing the same source checkout, absolute paths must be identical in build and analysis steps
Our multi project C++ structure in like below; when we compile project create build_dir in project_root path. All modules compiles and theirs object files occurs in build_dir.
Project_Root
├──
Common
Thirdparty
Sourcedirectory_X
├── X
├── x_feature.cpp
├── CmakeList.txt
Sourcediretory_Y
├──Y
├── y_feature.cpp
├── CmakeList.txt
Source_directory_Z
├── Z
├── z_feature.cpp
├── CmakeList.txt
CmakeList.txt
build_dir
├── X (includes object file)
├── Y
├── Z
We followed this guides.
https://docs.sonarqube.org/latest/analysis/languages/cfamily/
SonarScanner | SonarQube Docs (Running SonarScanner from the zip file)
We have created project as manually and set it according to local on sonarqube.
Firstly we want to analysis only project X module
Build Wrapper command;
cd build_dir
build-wrapper-linux-x86-64 --out-dir ./bw-output make Target_X -j3
Sonarscanner;
sonar-scanner \
-Dsonar.projectKey=my_project \
-Dsonar.sources=X \
-Dsonar.cfamily.build-wrapper-output=build_dir/bw-output \
-Dsonar.projectBaseDir={Project_Root_Path} \
-Dsonar.host.url=http://.........:9000 \
-Dsonar.login=....................................
According to output log, sonar scanner can’t be find source file. Maybe Sonar scanner needs to object file? Each modules source files (.cpp) are exist in the own project directory. But object file exist in the Project_Root/build_dir.
Should source and object files be under the own project directory path?