Build wrapper doesn't create compilation database with maven

  • Operating system: Windows 11
  • SonarLint plugin version: 4.12.0
  • Programming language you’re coding in: C++ with maven as compiler
  • Is connected mode used: yes
    • Connected to SonarCloud or SonarQube (and which version): 9.9

And a thorough description of the problem / question:

Hi,

I’m running a dev container (docker) with the sonarlint plugin installed under Visual Studio code (version 1.90.2). And would like to use the compile commands database to analyze the project locally.

To do this I’m trying to run the build wrapper documented here: Running an analysis - SonarLint Documentation - VS Code (under heading Using Sonar’s Build Wrapper) where it specifies that a compile_commands.json file will be outputted. Sadly I do not see that file, everytime I run the command I get two files; build-wrapper-dump.json and build-wrapper.log.

The command that I run is as follows:
build-wrapper-linux-x86-64 --out-dir ./dbWrapper mvn … [project specific parameters].

The project it self will build correctly without a problem (also while running the command) and see this back in the log file at the end Tue Nov 26 15:11:55 2024: returned with code: 0.

So my question is; how can I create a compile_commands.json file using the build wrapper under a docker container (linux)? My colleague was already able to do this directly under windows using a msvc compiler but I would like to do it under windows using the GCC/G++ compiler.

Regards,

Wesley

Hey there.

Which build-wrapper are you using? The one downloaded from your SonarQube server, or the one downloaded from SonarCloud as the docs point to?

If the former, I would suggest giving the latter a try. At some point since 9.9, we changed the file format output by the build wrapper.

Hi Colin,

thanks for replying. I was indeed using the build wrapper that I downloaded from our SonarQube server. I have now tried to use the one in the documentation (link) and I’m happy to say that I have indeed a compile_commands.json file now!

Thank you!

Regards,

Wesley

I feel like something could be documented better here (always use the SonarQube Cloud one, not the one from your potentially outdated SonarQube server), so I’ll pass that onto our Docs team.

Perfect thank you. I actually suspected the one from our SonarQube would work better, potentionally better integration? So thats why I tried that one. But anyway thank you for the quick fix! I’m glad its not something to do with devcontainers or maven :).

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.