Skip to content

Commit fb93b1f

Browse files
committed
fix getting coverage report
1 parent 2541b36 commit fb93b1f

1 file changed

Lines changed: 48 additions & 1 deletion

File tree

android/build.gradle.kts

Lines changed: 48 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ val artifactId = "android"
1919

2020
// Configure JaCoCo version
2121
jacoco {
22-
toolVersion = "0.8.10"
22+
toolVersion = "0.8.11"
2323
}
2424

2525
android {
@@ -125,4 +125,51 @@ mavenPublishing {
125125
url = "https://github.com/formbricks/android"
126126
}
127127
}
128+
}
129+
130+
// Add JaCoCo tasks
131+
tasks.register<JacocoReport>("jacocoAndroidTestReport") {
132+
dependsOn("connectedDebugAndroidTest")
133+
134+
reports {
135+
xml.required.set(true)
136+
html.required.set(true)
137+
}
138+
139+
val fileFilter = listOf(
140+
"**/R.class",
141+
"**/R\$*.class",
142+
"**/BuildConfig.*",
143+
"**/Manifest*.*",
144+
"**/*Test*.*",
145+
"android/databinding/**/*.class",
146+
"android/databinding/*Binding.*",
147+
"android/BuildConfig.*",
148+
"**/*\$*.*",
149+
"**/Lambda\$*.class",
150+
"**/Lambda.class",
151+
"**/*Lambda.class",
152+
"**/*Lambda*.class",
153+
"**/*_MembersInjector.class",
154+
"**/Dagger*Component.class",
155+
"**/Dagger*Component\$*.class",
156+
"**/*Module_*Factory.class"
157+
)
158+
159+
val debugTree = fileTree(mapOf(
160+
"dir" to layout.buildDirectory.dir("tmp/kotlin-classes/debug").get().asFile,
161+
"excludes" to fileFilter
162+
))
163+
164+
val mainSrc = "${project.projectDir}/src/main/java"
165+
166+
sourceDirectories.setFrom(files(mainSrc))
167+
classDirectories.setFrom(files(debugTree))
168+
executionData.setFrom(fileTree(mapOf(
169+
"dir" to layout.buildDirectory.get().asFile,
170+
"includes" to listOf(
171+
"outputs/code_coverage/debugAndroidTest/connected/**/*.ec",
172+
"outputs/code_coverage/debugAndroidTest/connected/**/*.exec"
173+
)
174+
)))
128175
}

0 commit comments

Comments
 (0)