ERROR: Error during SonarQube Scanner execution File <path>.java can't be indexed twice

I’ve Sonar version 6.0 and there following command scans perfectly -

/home/oracle/jenkins/tools/hudson.plugins.sonar.SonarRunnerInstallation/Sonar6/bin/sonar-scanner -e -Dsonar.web.javaOpts=-Xmx2G -Dsonar.host.url=http://ip-address:9000/ -Dsonar.projectKey=BI7_9 -Dsonar.projectName=BI7_9 -Dsonar.analysis.mode=publish -Dsonar.issuesReport.html.enable=true -Dsonar.issuesReport.console.enable=true -Dsonar.projectBaseDir=/home/oracle/jenkins/workspace/RedmineAndReviewboardProject/SVNCheckout@8/branch_dev

Now I’ve another Sonar server with version 7.6 and if same above is executed by changing ip of new sonar server, it fails with following -

ERROR: Error during SonarQube Scanner execution
File <path>.java can't be indexed twice. Please check that inclusion/exclusion patterns 
produce disjoint sets for main and test files

Please guide me what settings I need to do on latest sonar server in order it to work.

Hi,

By the time you get to SonarQube version 7.6 - which is still past EOL; you should upgrade to 7.9.3 (LTS) or 8.2 (8.3 imminent) at your earliest convenience - a few things have changed. Let’s break down your analysis command:

-e

Not sure what this is supposed to do, so I’ll skip it

-Dsonar.web.javaOpts=-Xmx2G

This is a server-side option. Won’t do you any good here.

-Dsonar.host.url=http://ip-address:9000/

:+1:

-Dsonar.projectKey=BI7_9 -Dsonar.projectName=BI7_9

:+1:

-Dsonar.analysis.mode=publish 
-Dsonar.issuesReport.html.enable=true 
-Dsonar.issuesReport.console.enable=true 

These have all gone away. You can simply drop them

-Dsonar.projectBaseDir=/home/oracle/jenkins/workspace/RedmineAndReviewboardProject/SVNCheckout@8/branch_dev

This is most likely your problem. By default the analysis base directory will be the directory from which analysis is executed. No need to re-specify it from root. Simply cd into the project directory and fire off analysis. If after doing that you still get this error, then we’ll probably need to know more about the structure of your project.

 
HTH,
Ann