SonarCloud android project with CPP native code

Template for a good new topic, formatted with Markdown:

  • Bitbucket Cloud
  • On premises CI
  • Scanner command used when applicable (private details masked)
  • Java and C++

Hello we are trying to use SonarCloud to validate our code and to have the results in the same project’s page.
Our project is an android project (Java) with native code (C++).
I’ve read that it needs to be done in two steps due to the fact we use 2 different languages in the same project.
My first step is to generate the “build-wrapper-dump.json” file by running the build-wrapper command

build-wrapper-linux-x86-64 --out-dir . ./gradlew clean assembleArmRelease --no-daemon

The second step is to run ./gradlew sonar

It succeeds but it only reports the Java code but not the CPP code.

Attempted workarounds:
If I run the scanner command with the same “build-wrapper-dump.json” it generates the report with only CPP code and no JAVA, I have to exclude the Java files otherwise the command fails.

If I run the scanner command, results get published but they get replaced if I run the ./gradlew sonar command for the java code.
Seems the results get overridden.

Is there a way to have the results of the multiple languages used in my project in a single report?

Hope it makes sense,

Do not share screenshots of logs – share the text itself (bonus points for being well-formatted)!


Welcome to the community!

You’re on the right track. Just a few things:

I think it would be cleaner if you designated a subdir for this. It’s probably not the root of your problem, but … like I said, it would be tidier.

SonarScanner for Gradle picks up the location of the source files from the build environment, which typically is very Java-centric. From your first command, you’re apparently handling the C++ build with Gradle, but I’m not confident your second command is actually including those source files in the list, so try overriding with either a property in the build config or on the command line: -Dsonar.sources=.