we have an open source project, Few of our builds are failing at sonar scanner step due to java.lang.IllegalStateException: The “build-wrapper-dump.json” file was found but 0 C/C++/Objective-C files were analyzed. we are able to generate the reports and publish to sonar cloud for some of the repos with the same configuration.
Hi @SaikrishnaBairamoni,
Do you run build-wrapper from the same directory as sonar-scanner?
Can you, please, share the “build-wrapper-dump.json” file, as well as the “build-wrapper.log” that should be in the same directory as “build-wrapper-dump.json”?
Also if I use sonar.sources=. I’m getting this error
ERROR: File velodyne_lidar_driver_wrapper/CMakeLists.txt can’t be indexed twice. Please check that inclusion/exclusion patterns produce disjoint sets for main and test files
The build-wrapper-dump.json should be produced by build-wrapper after the build command in the folder specified as --bw-output. According to your sonar-project.properties configuration:
It is in “/opt/carma/bw-output”. “build-wrapper.log” is stored in the same directory.
It is also mentioned in the analysis log:
INFO: Using build-wrapper output: /opt/carma/bw-output/build-wrapper-dump.json
Also if I use sonar.sources=. I’m getting this error
ERROR: File velodyne_lidar_driver_wrapper/CMakeLists.txt can’t be indexed twice. Please check that inclusion/exclusion patterns produce disjoint sets for main and test files
this is a problem, and might be the cause of your analysis issue. In what context do you see this error message?
I know this is hard to hear (read) but please be patient. You’re interacting with one of the developers of these features and all our devs have a lot going on. And as a side note, tomorrow is a holiday in Geneva, so it may be a couple days more before he’s able to get back to you.
I would like to reach out to you for assistance as I not able to find out the root cause of the issue, Most of the our other repos are getting the reports which uses same base image scripts for sonar (carma-base/code_coverage at develop · usdot-fhwa-stol/carma-base · GitHub). I tried modifying the sonar properties but got the same errors. Could you please help me with this issue and let me know if you need any other information. Thank you!
Hi @SaikrishnaBairamoni
I apologize for the long delay. We are currently very busy making sure the upcoming LTS release of SQ is solid.
From the Build Wrapper JSON file you’ve attached I discovered that it did not manage to intercept any compilation commands. This means that the issue lies in the way you build the project under the build-wrapper invocation:
building the project in a container (for example in a Docker container), or
building it on a remote host.
Neither mode is supported by Build Wrapper (they escape our process interception mechanism).
From your build logs I infer that you are using a build-automation tool colcon, which I am not familiar with, but which is likely doing one of the above.
Can you check if you are using Docker containers or remote hosts for the build?
Unfortunately, I do not have the bandwidth to compare build configurations of multiple projects.
I can only give you a hint on how to go about investigating the issue.
As I said, Build Wrapper does not support “remote execution”, be it a cluster with the compilation done by several worker machines, or a cluster of several virtual machines, or a constellation of multiple independent processes such as multiple Docker containers.
The reason is all the above prevents Build Wrapper from intercepting compilation commands since Build Wrapper is only run at the coordinator node and does not see the workers.
You can try to run a sequential build (see --executor sequential). I have no experience with colcon, but chances are it will run compilation as a subprocess of the original process which is supported by Build Wrapper.
If this does not help, you can give up on the Build Wrapper, and generate a compilation database instead. SonarCloud supports it as a way of configuring C and C++ analysis, see the " Analysis Steps Using Compilation Database" here.