Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ sonar {
property("sonar.projectKey", "rashidi_spring-boot-tutorials")
property("sonar.organization", "rashidi-github")
property("sonar.host.url", "https://sonarcloud.io")
property("sonar.java.binaries", "**/build/classes")

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Using a hardcoded path like **/build/classes is not ideal as it's brittle and can incorrectly include test classes in the SonarQube analysis, which can skew metrics like code coverage. A more robust approach is to dynamically generate the path from your subprojects' source sets. This ensures only production code binaries are included and automatically adapts to your project structure, for instance if you add Kotlin modules in the future.

        property("sonar.java.binaries", subprojects.flatMap { it.sourceSets.getByName("main").output.classesDirs }.joinToString(","))

property("sonar.coverage.jacoco.xmlReportPaths", "${layout.buildDirectory.get()}/reports/jacoco/testCodeCoverageReport/testCodeCoverageReport.xml")
}
}
Expand Down
Loading