Hello Team,
I have the following directory structure:
Project A β Src , resources (containing files: beans.xml, beans.xsd), TestSrc
Under resources directory I have dirA (containing files: test, testclasess.xml)
I defined the following properties:
sonar.sources=src/,resources/
sonar.tests=testsrc/,resources/ (also tried defining only testsrc/)
sonar.test.inclusions=resources/dirA/*test*'
sonar.exclusions=**/resources/**/*test*
I receive the error that testclasses.xml cant be indexed twice. Same with other file under resources for beans.xml, beans.xsd.
Please advise on how to fix this issue.
Colin
(Colin)
August 15, 2023, 9:01am
2
Hey there.
What language(s) are you analyzing?
Hello @Colin ,
We have java, xml, xsd, css files.
Use ant to build the project.
Thanks and Regards
Ramya
Colin
(Colin)
August 15, 2023, 2:23pm
4
Thanks. Keep in mind two things:
If youβre using the SonarScanner for Ant , it has been deprecated and youβll need to migrate (as documeted) to the SonarScanner CLI .
If youβre already using the former, then itβs time to look at how the analysis parameters are configured.
Ramya Yarru:
I defined the following properties:
sonar.sources=src/,resources/
sonar.tests=testsrc/,resources/ (also tried defining only testsrc/)
sonar.test.inclusions=resources/dirA/*test*'
sonar.exclusions=**/resources/**/*test*
When I analyze a project like this:
.
βββ resources
β βββ dirA
β β βββ testclasses.xml
β βββ sourcexml.xml
βββ sonar-project.properties
βββ src
β βββ Person.js
βββ testsrc
βββ Cat.js
Using the sonar-project.properties file you shared
sonar.sources=src/,resources/
sonar.tests=testsrc/,resources/
sonar.test.inclusions=resources/dirA/*test*'
sonar.exclusions=**/resources/**/*test*
I get a successful scan. testsrc
needs to be added to sonar.test.inclusions
to correctly index the files as test code, but otherwise it functions well. Am I missing something in trying to reproduce it?
Can you also mention what version of SonarQube youβre using?
Hello @Colin
Thanks for the help.
Figured out that these files were being scanned twice and hence we were receiving the error. This is now resolved.
Thanks again !!
1 Like