Sonar C++ wrapper failing in parsing build-wrapper-dump.json

Hi Team,
Please help for the issue of C++ project.

I am able to generate the json file. and running build command and sonar scanner with wrapper as both running in same instance of compose. All is well till json creation but when it parses it gives below error.

10:40:41.272 DEBUG: ‘src/agent/’ generated metadata with charset ‘UTF-8’
10:40:41.286 INFO: Cache is explicitly disabled: Optional[false]
10:40:41.299 WARN:
was generated using 6.20.3 build-wrapper version,
which does not match analyzer version.

Please download matching version from the server

10:40:41.347 INFO: ------------------------------------------------------------------------
10:40:41.347 INFO: ------------------------------------------------------------------------
10:40:41.347 INFO: Total time: 17.778s
10:40:41.399 INFO: Final Memory: 20M/70M
10:40:41.399 INFO: ------------------------------------------------------------------------
10:40:41.399 ERROR: Error during SonarScanner execution
java.lang.IllegalStateException: End of input at line 155 column 16 path $.captures[7]
at com.sonar.cpp.plugin.CFamilySensor.process(
at com.sonar.cpp.plugin.CFamilySensor.process(
at com.sonar.cpp.plugin.CFamilySensor.execute(
at org.sonar.scanner.sensor.AbstractSensorWrapper.analyse(
at org.sonar.scanner.sensor.ModuleSensorsExecutor.execute(
at org.sonar.scanner.sensor.ModuleSensorsExecutor.execute(
at org.sonar.scanner.scan.ModuleScanContainer.doAfterStart(
at org.sonar.core.platform.ComponentContainer.startComponents(
at org.sonar.core.platform.ComponentContainer.execute(
at org.sonar.scanner.scan.ProjectScanContainer.scan(
at org.sonar.scanner.scan.ProjectScanContainer.scanRecursively(
at org.sonar.scanner.scan.ProjectScanContainer.doAfterStart(
at org.sonar.core.platform.ComponentContainer.startComponents(
at org.sonar.core.platform.ComponentContainer.execute(
at org.sonar.scanner.bootstrap.GlobalContainer.doAfterStart(
at org.sonar.core.platform.ComponentContainer.startComponents(
at org.sonar.core.platform.ComponentContainer.execute(
at org.sonar.batch.bootstrapper.Batch.doExecute(
at org.sonar.batch.bootstrapper.Batch.execute(
at org.sonarsource.scanner.api.internal.batch.BatchIsolatedLauncher.execute(
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.base/java.lang.reflect.Method.invoke(Unknown Source)
at org.sonarsource.scanner.api.internal.IsolatedLauncherProxy.invoke(
at com.sun.proxy.$Proxy0.execute(Unknown Source)
at org.sonarsource.scanner.api.EmbeddedScanner.doExecute(
at org.sonarsource.scanner.api.EmbeddedScanner.execute(
at org.sonarsource.scanner.cli.Main.execute(
at org.sonarsource.scanner.cli.Main.execute(
at org.sonarsource.scanner.cli.Main.main(
Caused by: End of input at line 155 column 16 path $.captures[7]
build-wrapper-dump.json (73.4 KB)

Hello @Himanshu_Tyagi and welcome to our community!

Your build-wrapper-dump.json is incomplete so the analysis is failing. It means that the execution of your build with build-wrapper did not succeed.

Could you re-run the build-wrapper with your clean build command and make sure that the build succeeded? If it succeeds, could you share the build-wrapper.log please?

I did investigate on this again based on your comment. And I am success in doing this using sonarscanner cli. But I want it through gradle and it is failing saying.

Caused by: 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

Did you disable the Gradle daemon (--no-daemon) while building with build-wrapper?

In order to help you, could you please share the build-wrapper.log as well as the build-wrapper.json?