Skip to content

Fix SonarQube "indexed twice" error for dispatcher-agent sources#763

Merged
bedaHovorka merged 2 commits into
goal-10from
copilot/fix-sonarqube-analysis-error
Jul 12, 2026
Merged

Fix SonarQube "indexed twice" error for dispatcher-agent sources#763
bedaHovorka merged 2 commits into
goal-10from
copilot/fix-sonarqube-analysis-error

Conversation

Copilot AI commented Jul 12, 2026

Copy link
Copy Markdown
Contributor

SonarQube Gradle plugin v6+ auto-detects source sets for every Kotlin JVM subproject. With :dispatcher-agent paths also explicitly listed in the root sonar {} block, the scanner encountered the same files via two paths, causing:

File dispatcher-agent/src/main/kotlin/.../DispatchDecisionApplier.kt
can't be indexed twice. Please check that inclusion/exclusion patterns
produce disjoint sets for main and test files

Changes

  • build.gradle.kts (root): Remove dispatcher-agent/src/{main,test}/kotlin from sonar.sources/sonar.tests and remove dispatcher-agent binary paths from sonar.java.binaries/sonar.java.test.binaries. JUnit/JaCoCo aggregation paths stay in root. Added comment explaining the invariant.

  • dispatcher-agent/build.gradle.kts: Add explicit sonar {} block that owns this module's source/test/binary configuration — the correct multi-module Gradle pattern where each subproject declares its own SonarQube settings:

    sonar {
        properties {
            property("sonar.sources", "src/main/kotlin")
            property("sonar.tests", "src/test/kotlin")
            property("sonar.java.binaries", "build/classes/kotlin/main")
            property("sonar.java.test.binaries", "build/classes/kotlin/test")
            property("sonar.sourceEncoding", "UTF-8")
        }
    }
  • sonar-project.properties: Add dispatcher-agent paths to keep this file in sync (used for local CLI sonar-scanner runs, which have no Gradle subproject auto-detection).

…subproject

The SonarQube Gradle plugin v6+ auto-detects JVM subproject source sets.
Having dispatcher-agent paths in BOTH the root sonar {} block AND the
subproject's auto-detected sources caused:
  "File ... can't be indexed twice" (Issue #762)

Fix:
- Remove dispatcher-agent/src/{main,test}/kotlin from root sonar.sources/
  sonar.tests and java binary paths in build.gradle.kts
- Add explicit sonar {} block in dispatcher-agent/build.gradle.kts that
  claims src/main/kotlin and src/test/kotlin for this module
- Update sonar-project.properties to include dispatcher-agent paths for
  consistency with CLI sonar-scanner runs
Copilot AI changed the title [WIP] Fix SonarQube analysis: file indexed twice error in dispatcher-agent Fix SonarQube "indexed twice" error for dispatcher-agent sources Jul 12, 2026
Copilot AI requested a review from bedaHovorka July 12, 2026 11:00
@bedaHovorka bedaHovorka marked this pull request as ready for review July 12, 2026 13:02
@bedaHovorka bedaHovorka merged commit dba4fe5 into goal-10 Jul 12, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Fix SonarQube analysis: file indexed twice error in dispatcher-agent

2 participants