Skip to content
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion .github/workflows/sonarcloud.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ jobs:
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle') }}
restore-keys: ${{ runner.os }}-gradle
- name: Run tests, linting and coverage generation first
run: ./gradlew lint jacocoTestReport
run: ./gradlew lint createDebugUnitTestCoverageReport
- name: Build and analyze
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
Expand Down
3 changes: 2 additions & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ sonarqube {
property("sonar.androidLint.reportPaths", "helperlib/build/reports/lint-results-debug.xml")
property("sonar.projectVersion", project(":helperlib").ext.get("version") ?: "1.0")
property("sonar.tests", "src/test/java,src/test/kotlin")
property("sonar.coverage.jacoco.xmlReportPaths", "build/reports/jacoco/jacocoTestReport/jacocoTestReport.xml")
property("sonar.coverage.jacoco.xmlReportPaths", "**/build/reports/coverage/test/debug/report.xml")
property("sonar.java.binaries", "**/build/intermediates/javac/*/classes")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

high

The sonar.java.binaries property generally does not support wildcards and should point to specific directories. It is also missing the path to compiled Kotlin classes. Additionally, you should explicitly define sonar.sources to include Kotlin files and migrate the previous coverage exclusions (like R classes and BuildConfig) to sonar.coverage.exclusions to ensure the report remains accurate and consistent with the previous configuration.

        property("sonar.sources", "helperlib/src/main/java,helperlib/src/main/kotlin")
        property("sonar.java.binaries", "helperlib/build/intermediates/javac/debug/classes,helperlib/build/tmp/kotlin-classes/debug")
        property("sonar.coverage.exclusions", "**/R.class,**/R$*.class,**/BuildConfig.*,**/Manifest*.*,**/*Test*.*,android/**/*.*")

}
}
1 change: 0 additions & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ volley = { module = "com.android.volley:volley", version.ref = "volley" }

[plugins]
android-library = { id = "com.android.library", version.ref = "androidLibrary" }
jacoco = { id = "jacoco" }
kotlin-android = { id = "org.jetbrains.kotlin.android", version.ref = "kotlinAndroid" }
kotlin-serialization = { id = "org.jetbrains.kotlin.plugin.serialization", version.ref = "kotlinSerialization" }
sonarqube = { id = "org.sonarqube", version.ref = "sonarqube" }
Expand Down
42 changes: 0 additions & 42 deletions helperlib/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ plugins {
alias(libs.plugins.android.library)
alias(libs.plugins.kotlin.android)
alias(libs.plugins.kotlin.serialization)
alias(libs.plugins.jacoco)
}

ext.set("version", "2.3.2")
Expand Down Expand Up @@ -78,46 +77,5 @@ dependencies {
implementation(libs.volley)
}

tasks.register<JacocoReport>("jacocoTestReport") {
dependsOn("testDebugUnitTest")
group = "verification"
description = "Generate Jacoco coverage reports for the debug build."

reports {
xml.required.set(true)
html.required.set(true)
}

val fileFilter = listOf(
"**/R.class", "**/R$*.class", "**/BuildConfig.*", "**/Manifest*.*",
"**/*Test*.*", "android/**/*.*"
)

val buildDir = layout.buildDirectory.get().asFile.path

val debugTree = fileTree("$buildDir/intermediates/javac/debug/classes") {
exclude(fileFilter)
}
val kotlinDebugTree = fileTree("$buildDir/tmp/kotlin-classes/debug") {
exclude(fileFilter)
}

val mainSrc = "$projectDir/src/main/java"
val kotlinSrc = "$projectDir/src/main/kotlin"

sourceDirectories.setFrom(files(mainSrc, kotlinSrc))
classDirectories.setFrom(files(debugTree, kotlinDebugTree))

executionData.setFrom(
fileTree(buildDir) {
include(
"jacoco/testDebugUnitTest.exec",
"outputs/unit_test_code_coverage/debugUnitTest/testDebugUnitTest.exec"
)
}
)

}

// Apply the publish.gradle file
apply(from = "./publish.gradle")