Build.gradle file
plugins {
id 'org.springframework.boot' version '2.7.1'
id 'io.spring.dependency-management' version '1.0.11.RELEASE'
id 'java'
id 'jacoco'
id 'org.sonarqube' version '3.3'
}
group = 'com.sonar'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = '1.8'
repositories {
mavenCentral()
}
dependencies {
implementation 'org.springframework.boot:spring-boot-starter-web'
testImplementation 'org.springframework.boot:spring-boot-starter-test'
// https://mvnrepository.com/artifact/junit/junit
testImplementation group: 'junit', name: 'junit', version: '4.13.2'
}
tasks.named('test') {
useJUnitPlatform()
}
sonarqube {
properties {
}
}
jacocoTestReport {
reports {
xml.enabled true
}
}
test.finalizedBy jacocoTestReport
tasks.named('sonarqube').configure {
dependsOn test
}
sonar properties that I am using
sonar.java.binaries=build/classes
sonar.sources=src/main
sonar.tests=src/test
I am running sonarqube command everything working as expected but number of unit test cases not showing and when I am changing property of sonar.sources to this
sonar.sources=src
then both coverage and number of unit test cases showing but getting error in build
java can’t be indexed twice. Please check that inclusion/exclusion patterns produce disjoint sets for main and test files
I have used exlusions also but no luck .
Thanks in advance.