[英]How to configure sonar properties for C++ project
我正在嘗試為 C++ 項目生成聲納報告。 但是我收到“請為您的項目提供帶有 sonar.java.binaries 屬性的編譯類”錯誤。 我使用的是 SonarQube 數據中心版版本 7.9.4(內部版本 35981)。 我在 pom.xml 中擁有的 PFB 屬性。
<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>
我嘗試在 <sonar.language>c++</sonar.language> 中給出 c++、C++。
我有一個類似的問題,通過添加解決:
-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
您需要刪除“D”並將其調整為 XML 標簽(所有這些都可能不是必需的),但這可能會解決您的問題。
需要直接從你的SonarQube服務器下載Build Wrapper,使其版本與你的插件版本完美匹配。
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
基於操作系統提取相應的 zip 文件並將文件放入項目根目錄中。 使用下面的代碼運行 clean all。 它將生成 build-wrapper-dump.json 和 build-wrapper.log 文件。 您可以在 output 目錄中找到它們。
<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>
需要在 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>
現在運行聲納掃描儀來分析並生成報告。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.