现象说明
maven的java项目,测试用例和main所在的源码文件均符合缺省写法和格式,但是在使用mvn clean sonar:sonar进行 编译 时提示can't be indexed twice错误。
相关版本
使用如下相关版本信息:
错误信息提示
1 |
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传入如下信息即可解决(例):
1 2 3 4 |
sonar.sources=. sonar.tests=. sonar.test.inclusions=** /*Test*/** sonar.exclusions=**/*Test*/ ** |
参考内容
https://github测试数据/SonarOpenCommunity/sonar-cxx/wiki/FAQ
总结
以上就是这篇文章的全部内容了,希望本文的内容对大家的学习或者工作具有一定的参考学习价值,谢谢大家对的支持。如果你想了解更多相关内容请查看下面相关链接
原文链接:https://blog.csdn.net/liumiaocn/article/details/85063738
查看更多关于Sonar编译问题对应:File [...] cant be indexed twice.的详细内容...