Problem
SonarQube analysis is failing during the sonar Gradle task with the following error:
File dispatcher-agent/src/main/kotlin/cz/vutbr/fit/interlockSim/dispatcher/DispatchDecisionApplier.kt
can't be indexed twice. Please check that inclusion/exclusion patterns produce disjoint sets for
main and test files
This occurs in the .github/workflows/sonarqube.yml workflow (job #86623950861).
Root Cause
SonarQube is encountering the same Kotlin file in both main source and test source paths, causing a conflict during analysis. The sonar Gradle task is unable to resolve overlapping source/test directories.
Solution
Configure SonarQube's source inclusion/exclusion patterns in the build.gradle.kts to ensure main and test files don't overlap.
Add the following to your sonar configuration block:
sonar {
properties {
property("sonar.sources", "src/main")
property("sonar.tests", "src/test")
property("sonar.sourceEncoding", "UTF-8")
}
}
Verification Steps
- Ensure the project structure has main sources in
src/main/kotlin/ and test files in src/test/kotlin/
- Verify that no Kotlin files are duplicated between main and test source trees
- Trigger the SonarQube workflow manually or via a new push to verify the fix
Related Workflow
.github/workflows/sonarqube.yml - SonarCloud analysis workflow
- Triggered by:
.github/workflows/gradle-java21.yml completion
Problem
SonarQube analysis is failing during the
sonarGradle task with the following error:This occurs in the
.github/workflows/sonarqube.ymlworkflow (job #86623950861).Root Cause
SonarQube is encountering the same Kotlin file in both main source and test source paths, causing a conflict during analysis. The
sonarGradle task is unable to resolve overlapping source/test directories.Solution
Configure SonarQube's source inclusion/exclusion patterns in the
build.gradle.ktsto ensure main and test files don't overlap.Add the following to your
sonarconfiguration block:sonar { properties { property("sonar.sources", "src/main") property("sonar.tests", "src/test") property("sonar.sourceEncoding", "UTF-8") } }Verification Steps
src/main/kotlin/and test files insrc/test/kotlin/Related Workflow
.github/workflows/sonarqube.yml- SonarCloud analysis workflow.github/workflows/gradle-java21.ymlcompletion