Sonar编译问题对应:File [...] can't be indexed twice.
生活随笔
收集整理的這篇文章主要介紹了
Sonar编译问题对应:File [...] can't be indexed twice.
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
現象說明
maven的java項目,測試用例和main所在的源碼文件均符合缺省寫法和格式,但是在使用mvn clean sonar:sonar進行編譯時提示can’t be indexed twice錯誤。
相關版本
使用如下相關版本信息:
| JDK | 1.8 |
| Maven | 3.5.3 |
| Sonarqube | 5.6.5 |
錯誤信息提示
ERROR: Caused by: File [...] can't be indexed twice. Please check that inclusion/exclusion patterns produce disjoint sets for main and test files相關信息說明
maven的pom中對于源碼和測試代碼的指定可以通過如下設定進行:
- <sourceDirectory>源碼目錄</sourceDirectory>
- <testSourceDirectory>測試代碼目錄<testSourceDirectory>
sonar中對于源碼目錄和測試代碼目錄的設定可以通過如下方式進行:
- sonar.sources=源碼目錄
- sonar.tests=測試代碼目錄
對策
可以通過設定sonar的exclusion/inclusion屬性來解決問題。通過-D傳入如下信息即可解決(例):
sonar.sources=. sonar.tests=. sonar.test.inclusions=**/*Test*/** sonar.exclusions=**/*Test*/**參考內容
https://github.com/SonarOpenCommunity/sonar-cxx/wiki/FAQ
總結
以上是生活随笔為你收集整理的Sonar编译问题对应:File [...] can't be indexed twice.的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: python数据处理论文_用Python
- 下一篇: 什么是TOR 官方文档