软件编程
位置:首页>> 软件编程>> java编程>> Sonar编译问题对应:File [...] can't be indexed twice.

Sonar编译问题对应:File [...] can't be indexed twice.

作者:liumiaocn  发布时间:2023-11-25 11:07:28 

标签:sonar,编译,异常

现象说明

maven的java项目,测试用例和main所在的源码文件均符合缺省写法和格式,但是在使用mvn clean sonar:sonar进行编译时提示can't be indexed twice错误。

相关版本

使用如下相关版本信息:

Sonar编译问题对应:File [...] can't be indexed twice.

错误信息提示


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

来源:https://blog.csdn.net/liumiaocn/article/details/85063738

0
投稿

猜你喜欢

手机版 软件编程 asp之家 www.aspxhome.com