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

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

问题描述

我已将性能测试创建为我的主模块的 maven 子模块.所有的测试类都写在 src/ma​​in/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 可以工作了.

但问题是声纳构建失败并出现错误提示:不能被索引两次.很明显,我的 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天全站免登陆