Reputation: 213
I am trying to generate sonar report for C++ project. But I am getting "Please provide compiled classes of your project with sonar.java.binaries property" error. I am using SonarQube Data Center EditionVersion 7.9.4 (build 35981). PFB properties that i am having in pom.xml.
<sonar.maven.version>3.6.0.1398</sonar.maven.version>
<sonar.scm.enabled>true</sonar.scm.enabled>
<sonar.sources>.</sonar.sources>
<sonar.cfamily.build-wrapper-output>build_wrapper_output_directory</sonar.cfamily.build-wrapper-output>
<sonar.sourceEncoding>UTF-8</sonar.sourceEncoding>
I tried by giving c++, C++ in <sonar.language>c++</sonar.language>.
Upvotes: 0
Views: 3501
Reputation: 213
Need to download the Build Wrapper directly from your SonarQube server, so that its version perfectly matches your version of the plugin.
http://localhost:9000/static/cpp/build-wrapper-linux-x86.zip
http://localhost:9000/static/cpp/build-wrapper-macosx-x86.zip
http://localhost:9000/static/cpp/build-wrapper-win-x86.zip
Based on operating system extract respective zip file and place files into your project root directory. Use below code to run clean all. It will generate build-wrapper-dump.json and build-wrapper.log files. You can find them in output directory.
<execution>
<id>mfas-core-build-wrapper</id>
<phase>compile</phase>
<goals>
<goal>exec</goal>
</goals>
<configuration>
<executable>build-wrapper-linux-x86-64</executable>
<workingDirectory>${project.basedir}</workingDirectory>
<arguments>
<argument>--out-dir</argument>
<argument>${output}</argument>
<argument>make</argument>
<argument>clean</argument>
<argument>all</argument>
</arguments>
</configuration>
</execution>
Need to add below properties in pom.xml
<sonar.language>cxx</sonar.language>
<sonar.sources>.</sonar.sources>
<sonar.sourceEncoding>UTF-8</sonar.sourceEncoding>
<sonar.cfamily.build-wrapper-output>${output}</sonar.cfamily.build-wrapper-output>
<sonar.inclusions>**/*.c,**/*.h,**/*.xml</sonar.inclusions>
<sonar.exclusions>**/*.java</sonar.exclusions>
<sonar.cxx.file.suffixes>.c,.h</sonar.cxx.file.suffixes>
Now run sonar scanner to analysis and generate the report.
Upvotes: 0
Reputation: 701
I had a similar issue that was fixed by adding:
-Dsonar.language=cxx
-Dsonar.inclusions=**/*.cxx,**/*.cpp,**/*.cc,**/*.c,**/*.hxx,**/*.hpp,**/*.hh,**/*.h,**/*.r
-Dsonar.exclusions=**/*.java
-Dsonar.cxx.file.suffixes=.cxx,.cpp,.cc,.c,.hxx,.hpp,.hh,.h,.r
You'll need to remove the "D" and adapt this to XML tags (and all might not be necessary) but it may fix your issue.
Upvotes: 1