-
-
Notifications
You must be signed in to change notification settings - Fork 89
/
build.gradle
141 lines (119 loc) · 4.27 KB
/
build.gradle
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
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
plugins {
id 'com.android.application' version "${agpVersion}" apply false
id 'com.android.library' version "${agpVersion}" apply false
id 'org.jetbrains.kotlin.android' version "${kotlinVersion}" apply false
id 'org.jetbrains.kotlin.kapt' version "${kotlinVersion}" apply false
id 'com.google.devtools.ksp' version "1.9.23-1.0.19" apply false
id 'androidx.navigation.safeargs.kotlin' version "${navVersion}" apply false
id 'com.google.dagger.hilt.android' version "${hiltVersion}" apply false
id 'com.mikepenz.aboutlibraries.plugin' version "${aboutLibrariesVersion}" apply false
id 'com.google.gms.google-services' version '4.4.1' apply false // sed:free-build:remove
id 'com.google.firebase.crashlytics' version '2.9.9' apply false // sed:free-build:remove
id 'com.adarshr.test-logger' version '4.0.0' apply false
}
// project-wide constants for sharing configuration and dependency versions across modules.
project.ext {
deps = [
aboutLibrariesVersion: "${aboutLibrariesVersion}",
androidXCoreVersion : '1.12.0',
coroutinesVersion : '1.8.0',
hiltVersion : "${hiltVersion}",
kotlinVersion : "${kotlinVersion}",
lifecycleVersion : '2.7.0',
navVersion : "${navVersion}",
junitVersion : '4.13.2',
robolectricVersion : '4.11.1',
testCoreVersion : '1.5.0',
]
}
subprojects {
afterEvaluate { subproject ->
if (!subproject.hasProperty("android")) {
return
}
android {
compileSdk 34
defaultConfig {
minSdk 21
targetSdk 34
}
compileOptions {
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
}
kotlin {
jvmToolchain 17
}
kotlinOptions {
freeCompilerArgs += ["-opt-in=kotlinx.coroutines.ExperimentalCoroutinesApi"]
}
testOptions {
unitTests {
includeAndroidResources = true
}
}
}
jacoco {
toolVersion = '0.8.8'
}
subproject.tasks.withType(Test).configureEach {
testlogger.theme 'mocha'
jacoco {
includeNoLocationClasses = true
excludes = ['jdk.internal.*']
}
}
subproject.afterEvaluate {
def variants = []
if (subproject.plugins.hasPlugin("com.android.application")) {
variants += subproject.android.applicationVariants
} else if (subproject.plugins.hasPlugin("com.android.library")) {
variants += subproject.android.libraryVariants
}
variants.forEach { variant ->
def taskName = "test${variant.name.capitalize()}Coverage"
def testTask = "test${variant.name.capitalize()}UnitTest"
def srcDirs = ["src/main/java"]
if (variant.buildType != null) {
srcDirs += "src/${variant.buildType.name}/java" // e.g. debug
}
if (variant.flavorName != null) {
srcDirs += "src/${variant.flavorName}/java" // e.g. free
}
if (variant.buildType != null && variant.flavorName != null) {
srcDirs += "src/${variant.name}/java" // e.g. freeDebug
}
subproject.tasks.register(taskName, JacocoReport) {
group = 'Reporting'
description = "Generate Jacoco coverage reports for the ${variant.name} build variant."
dependsOn += testTask
sourceDirectories.setFrom(files(srcDirs))
classDirectories.setFrom(files(
fileTree(
dir: "${project.layout.buildDir}/tmp/kotlin-classes/${variant.name}",
excludes: ['**/R.class',
'**/R$*.class',
'**/*$ViewInjector*.*',
'**/*$ViewBinder*.*',
'**/BuildConfig.*',
'**/Manifest*.*']
))
)
executionData.setFrom(files(
fileTree(subproject.buildDir)
.include("jacoco/**/${testTask}.exec") // for api-client..?
.include("outputs/unit_test_code_coverage/**/${testTask}.exec") // for app..?
// and idk why they differ
))
reports {
xml.required = true
html.required = true
}
}
}
}
}
}
tasks.register('clean', Delete) {
delete rootProject.layout.buildDir
}