forked from Baghdad-Squad/Novix
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.gradle.kts
More file actions
111 lines (94 loc) · 3.05 KB
/
Copy pathbuild.gradle.kts
File metadata and controls
111 lines (94 loc) · 3.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
plugins {
alias(libs.plugins.android.application) apply false
alias(libs.plugins.kotlin.android) apply false
alias(libs.plugins.kotlin.compose) apply false
alias(libs.plugins.android.library) apply false
alias(libs.plugins.ksp) apply false
alias(libs.plugins.google.services) apply false
alias(libs.plugins.firebase.crashlytics) apply false
alias(libs.plugins.firebase.perf) apply false
jacoco
alias(libs.plugins.hilt.android) apply false
alias(libs.plugins.jetbrains.kotlin.jvm) apply false
}
jacoco {
toolVersion = "0.8.11"
}
/**
* When you need to exclude specific packages or classes from the Jacoco report,
* you can add them to this list.
* */
val excludedPackagesOrClasses = listOf(
"com.baghdad.entity",
"com.baghdad.design_system",
"com.baghdad.islamic_image_loader",
"com.baghdad.base",
"com.baghdad.islamic_image_loader",
"com.baghdad.repository.model",
"com.baghdad.repository.datasource.local",
)
val excludedPatterns = excludedPackagesOrClasses.flatMap { path ->
val patternBase = path.replace('.', '/')
listOf(
"**/$patternBase/**",
"**/$patternBase.class",
"**/$patternBase\$*.class"
)
}
val defaultExcludedPackagesOrClasses = listOf(
"**/R.class",
"**/R$*.class",
"**/BuildConfig.*",
"**/Manifest*.*",
"**/*_Impl*.*",
"**/ComposableSingletons*.*",
"**/*Kt.class",
"**/MainActivity.class",
"**/di/**",
"**/ui/theme/**",
)
val allExcludes = defaultExcludedPackagesOrClasses + excludedPatterns
val classDirs = subprojects.mapNotNull { subproject ->
val path = "${subproject.buildDir}/tmp/kotlin-classes/debug"
val dir = file(path)
if (dir.exists()) {
fileTree(dir) {
exclude(allExcludes)
}
} else null
}
val execPaths = listOf(
"**/build/jacoco/testDebugUnitTest.exec",
"**/build/outputs/unit_test_code_coverage/debugUnitTest/testDebugUnitTest.exec"
)
val sourceDirs = subprojects.flatMap {
listOf(
"${it.projectDir}/src/main/java",
"${it.projectDir}/src/main/kotlin"
)
}.filter { file(it).exists() }
tasks.register<JacocoReport>("jacocoTestReport") {
dependsOn(subprojects.map { it.path + ":testDebugUnitTest" })
executionData.setFrom(fileTree(rootDir).matching { include(execPaths) })
classDirectories.setFrom(classDirs)
sourceDirectories.setFrom(files(sourceDirs))
reports {
html.required.set(true)
xml.required.set(true)
csv.required.set(false)
html.outputLocation.set(file("app/build/reports/jacoco/jacocoTestReport/html"))
xml.outputLocation.set(file("app/build/reports/jacoco/jacocoTestReport/jacocoTestReport.xml"))
}
}
tasks.register<JacocoCoverageVerification>("jacocoTestCoverageVerification") {
dependsOn("jacocoTestReport")
executionData.setFrom(fileTree(rootDir).matching { include(execPaths) })
classDirectories.setFrom(classDirs)
violationRules {
rule {
limit {
minimum = "0.80".toBigDecimal()
}
}
}
}