Manza
Manza

Reputation: 3527

Sonar error in multi language project: File can't be indexed twice

I'm trying to setup sonar to analyze both java and javascript sources. I have a standard structure maven project. Following THIS example I've added the line

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

But when I run

mvn clean install sonar:sonar

I get the following error

[ERROR] Failed to execute goal 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] can't be indexed twice. Please check that inclusion/exclusion patterns produce disjoint sets for 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 any help!

UPDATE

1# Tried Akash Rajbanshi suggestion: error disappeared but js code is not analyzed and also sonar doesn't analyze the test folder

2# tried to put <sonar.language>js</sonar.language> and the js code is actually analyzed but java code is not (that was just a test)

I'm kind of stuck

Upvotes: 3

Views: 7409

Answers (2)

BMacedo
BMacedo

Reputation: 778

In order to make SonarQube analyse your tests as well, you should also set the "sonar.tests" property:

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

Upvotes: 2

Akash Rajbanshi
Akash Rajbanshi

Reputation: 1593

You can use this instead:

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

Upvotes: 0

Related Questions