不能被索引两次-testSourceDirectory和sourceDirectory相同 [英] can't be indexed twice - testSourceDirectory and sourceDirectory are same

查看:1065
本文介绍了不能被索引两次-testSourceDirectory和sourceDirectory相同的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经创建了性能测试作为主模块的Maven子模块.所有测试类都在src/ main /java下编写,而不是src/ test /java

I have created performance test as a maven submodule to my main module. All the test classes are written under src/main/java and not src/test/java

我能够将项目打包为jar并运行它以对我的项目进行性能测试.

I am able to package the project as jar and run it to performance test my project.

我想执行mvn test.为了使mvn test工作,我应该设置<testSourceDirectory>值.在这种情况下,我将代码保存在src/main/java中,将其设置为:

I wanted to execute mvn test. For mvn test to work I should have <testSourceDirectory> value set. As in this case I have my code in src/main/java I set this to :

<testSourceDirectory>src/main/java</testSourceDirectory>

现在mvn test有效.

但是问题是声纳构建失败,并出现错误提示:can't be indexed twice.对于我的pom testSourceDirectorysourceDirectory相同,这是显而易见的.

But the Problem is sonar build fails with error complaining: can't be indexed twice. Which is obvious as for my pom testSourceDirectory and sourceDirectory are same.

[ERROR] Failed to execute goal 
org.codehaus.mojo:sonar-maven-plugin:2.5:sonar (default-cli) 
   on project Blah: File [relative=XYZ.java, abs=/Path/XYZ.java] can't be indexed twice. 
Please check that inclusion/exclusion patterns produce 
disjoint sets for main and test files -> 

如何解决此问题?

推荐答案

我遇到了同样的问题.最后,借助以下文档解决了该问题:-

I was facing the same problem. Finally, solved it with help of below documentation:-

https://github.com/SonarOpenCommunity/sonar-cxx/wiki/FAQ

问题:错误:原因:文件[...]不能被索引两次.

A:如果出现以下错误,则必须验证您的排除/包含 特性.请检查是否产生包含/排除模式 源文件和测试文件的不相交集

A: In case of below error you have to verify your exclusion/inclusion properties. Please check that inclusion/exclusion patterns produce disjoint sets for source and test files

错误:原因:文件[...]不能被索引两次.请检查一下 包含/排除模式产生用于主测试和测试的不相交集 文件一个示例可能看起来像这样:

ERROR: Caused by: File [...] can't be indexed twice. Please check that inclusion/exclusion patterns produce disjoint sets for main and test files An example could look like this:

sonar.sources=.
sonar.tests=.
sonar.test.inclusions=**/*Test*/**
sonar.exclusions=**/*Test*/**

这篇关于不能被索引两次-testSourceDirectory和sourceDirectory相同的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆