Sonar error in multi-language project: file cannot be indexed twice

I am trying to set up sonar to parse both java and javascript sources. I have a standard maven project. Following THIS I added the line

<properties>
    <sonar.sources>src</sonar.sources>
</properties>

      

But when I run

mvn clean install sonar: sonar

I am getting the following error

[ERROR] Failed to execute target org.codehaus.mojo: sonar-maven-plugin: 2.5: sonar (default-cli) on project myproject: File [moduleKey = myproject: myproject, relative = SRC / test / Java / COM / MyProject /API/v1/ControllerTest.java, basedir = C: \ sources \ project] cannot be indexed twice. Check that the include / exclude patterns create disjoint sets for the main and test files → [Help 1]

"ControllerTest.java" is the first file in the /src/test/java/../ .. folder

Project structure:

enter image description here

Any hints? Thanks in advance for your help!

UPDATE

1 # Tried Akash Rajbanshi's suggestion: the error went away but the js code is not parsed and also sonar is not parse the test folder

2 # tried to put <sonar.language>js</sonar.language>

and the js code is actually parsed, but the java code is not (it was just a test)

I'm kind of stuck

+3


source to share


2 answers


For SonarQube to parse your tests, you must also set the "sonar.tests" property:



<properties>
    <sonar.sources>src/main</sonar.sources>
    <sonar.tests>src/test</sonar.tests>
</properties>

      

+2


source


You can use this instead:



<properties>
   <sonar.sources>src/main</sonar.sources>
</properties>

      

0


source







All Articles