1
+
2
+ import java.io.FileInputStream
3
+ import java.util.Properties
4
+
1
5
plugins {
6
+ jacoco
2
7
alias(libs.plugins.androidApplication)
3
8
alias(libs.plugins.jetbrainsKotlinAndroid)
4
9
alias(libs.plugins.ktfmt)
10
+ alias(libs.plugins.gms)
5
11
alias(libs.plugins.sonar)
6
12
id(" jacoco" )
7
13
}
8
14
9
15
android {
10
- namespace = " com.android.sample "
16
+ namespace = " com.android.unio "
11
17
compileSdk = 34
12
18
19
+ // Load the API key from local.properties
20
+ val localProperties = Properties ()
21
+ val localPropertiesFile = rootProject.file(" local.properties" )
22
+ if (localPropertiesFile.exists()) {
23
+ localProperties.load(FileInputStream (localPropertiesFile))
24
+ }
25
+
26
+ val mapsApiKey: String = localProperties.getProperty(" MAPS_API_KEY" ) ? : " "
27
+
28
+
13
29
defaultConfig {
14
- applicationId = " com.android.sample "
15
- minSdk = 28
30
+ applicationId = " com.android.unio "
31
+ minSdk = 29
16
32
targetSdk = 34
17
33
versionCode = 1
18
34
versionName = " 1.0"
@@ -21,55 +37,69 @@ android {
21
37
vectorDrawables {
22
38
useSupportLibrary = true
23
39
}
40
+ manifestPlaceholders[" MAPS_API_KEY" ] = mapsApiKey
24
41
}
25
42
26
43
buildTypes {
27
44
release {
28
45
isMinifyEnabled = false
29
46
proguardFiles(
30
- getDefaultProguardFile(" proguard-android-optimize.txt" ),
31
- " proguard-rules.pro"
47
+ getDefaultProguardFile(" proguard-android-optimize.txt" )," proguard-rules.pro"
32
48
)
33
49
}
34
-
35
50
debug {
36
51
enableUnitTestCoverage = true
37
52
enableAndroidTestCoverage = true
38
53
}
39
54
}
40
-
41
- testCoverage {
42
- jacocoVersion = " 0.8.8"
55
+ compileOptions {
56
+ sourceCompatibility = JavaVersion .VERSION_11
57
+ targetCompatibility = JavaVersion .VERSION_11
58
+ }
59
+ kotlinOptions {
60
+ jvmTarget = " 11"
43
61
}
44
-
45
62
buildFeatures {
46
63
compose = true
47
64
}
48
-
49
65
composeOptions {
50
- kotlinCompilerExtensionVersion = " 1.4.2 "
66
+ kotlinCompilerExtensionVersion = " 1.5.1 "
51
67
}
52
-
53
- compileOptions {
54
- sourceCompatibility = JavaVersion .VERSION_1_8
55
- targetCompatibility = JavaVersion .VERSION_1_8
56
- }
57
-
58
- kotlinOptions {
59
- jvmTarget = " 1.8"
60
- }
61
-
62
68
packaging {
63
69
resources {
64
70
excludes + = " /META-INF/{AL2.0,LGPL2.1}"
71
+ merges + = " META-INF/LICENSE.md"
72
+ merges + = " META-INF/LICENSE-notice.md"
73
+ excludes + = " META-INF/LICENSE-notice.md"
74
+ excludes + = " META-INF/LICENSE.md"
75
+ excludes + = " META-INF/LICENSE"
76
+ excludes + = " META-INF/LICENSE.txt"
77
+ excludes + = " META-INF/NOTICE"
78
+ excludes + = " META-INF/NOTICE.txt"
65
79
}
66
80
}
67
81
68
82
testOptions {
69
83
unitTests {
70
84
isIncludeAndroidResources = true
85
+
71
86
isReturnDefaultValues = true
72
87
}
88
+ packagingOptions {
89
+ jniLibs {
90
+ useLegacyPackaging = true
91
+ }
92
+ }
93
+ }
94
+
95
+
96
+ buildFeatures {
97
+ compose = true
98
+ buildConfig = true
99
+ }
100
+
101
+ kotlinOptions {
102
+ jvmTarget = " 11"
73
103
}
74
104
75
105
// Robolectric needs to be run only in debug. But its tests are placed in the shared source set (test)
@@ -113,12 +143,42 @@ fun DependencyHandlerScope.globalTestImplementation(dep: Any) {
113
143
}
114
144
115
145
dependencies {
146
+
147
+ implementation(platform(libs.firebase.bom))
148
+ implementation(libs.google.firebase.auth.ktx)
149
+
150
+ implementation(libs.androidx.lifecycle.viewmodel.ktx)
151
+ implementation(libs.androidx.lifecycle.livedata.ktx)
152
+
153
+ implementation(libs.kotlinx.coroutines.core)
154
+ implementation(libs.kotlinx.coroutines.android)
155
+
156
+ // Core
157
+ implementation(libs.core.ktx)
116
158
implementation(libs.androidx.core.ktx)
159
+ implementation(libs.androidx.lifecycle.runtime.ktx)
160
+ implementation(libs.androidx.activity.compose)
117
161
implementation(libs.androidx.appcompat)
162
+ implementation(libs.androidx.constraintlayout)
163
+ implementation(libs.androidx.fragment.ktx)
164
+ implementation(libs.kotlinx.serialization.json)
165
+
166
+ // Jetpack Compose UI
167
+ implementation(libs.androidx.ui)
168
+ implementation(libs.androidx.ui.tooling.preview)
169
+ implementation(libs.androidx.ui.graphics)
170
+ implementation(libs.androidx.material)
171
+ implementation(libs.androidx.material3)
172
+ implementation(libs.androidx.navigation.compose)
173
+ implementation(platform(libs.androidx.compose.bom))
174
+ testImplementation(libs.test.core.ktx)
175
+ debugImplementation(libs.androidx.ui.tooling)
176
+ debugImplementation(libs.androidx.ui.test.manifest)
118
177
implementation(libs.material)
178
+
119
179
implementation(libs.androidx.lifecycle.runtime.ktx)
120
180
implementation(platform(libs.compose.bom))
121
- testImplementation(libs.junit)
181
+
122
182
globalTestImplementation(libs.androidx.junit)
123
183
globalTestImplementation(libs.androidx.espresso.core)
124
184
@@ -147,9 +207,56 @@ dependencies {
147
207
globalTestImplementation(libs.kaspresso.compose)
148
208
149
209
// ---------- Robolectric ------------
210
+
211
+ // Navigation
212
+ implementation(libs.androidx.navigation.compose)
213
+ implementation(libs.androidx.navigation.fragment.ktx)
214
+ implementation(libs.androidx.navigation.ui.ktx)
215
+
216
+ // Google Service and Maps
217
+ implementation(libs.play.services.maps)
218
+ implementation(libs.maps.compose)
219
+ implementation(libs.maps.compose.utils)
220
+ implementation(libs.play.services.auth)
221
+
222
+ // Firebase
223
+ implementation(libs.firebase.database.ktx)
224
+ implementation(libs.firebase.firestore)
225
+ implementation(libs.firebase.ui.auth)
226
+ implementation(libs.firebase.auth.ktx)
227
+ implementation(libs.firebase.auth)
228
+
229
+ // Networking with OkHttp
230
+ implementation(libs.okhttp)
231
+
232
+ // Testing Unit
233
+ testImplementation(libs.junit)
234
+ androidTestImplementation(libs.mockk)
235
+ androidTestImplementation(libs.mockk.android)
236
+ androidTestImplementation(libs.mockk.agent)
237
+ testImplementation(libs.json)
238
+
239
+ // Test UI
240
+ androidTestImplementation(libs.androidx.junit)
241
+ androidTestImplementation(libs.androidx.espresso.core)
242
+ androidTestImplementation(libs.androidx.espresso.intents)
243
+ androidTestImplementation(libs.androidx.ui.test.junit4)
244
+ androidTestImplementation(platform(libs.androidx.compose.bom))
245
+ testImplementation(libs.mockito.core)
246
+ testImplementation(libs.mockito.inline)
247
+ testImplementation(libs.mockito.kotlin)
248
+ androidTestImplementation(libs.mockito.android)
249
+ androidTestImplementation(libs.mockito.kotlin)
150
250
testImplementation(libs.robolectric)
251
+ androidTestImplementation(libs.kaspresso)
252
+ androidTestImplementation(libs.kaspresso.allure.support)
253
+ androidTestImplementation(libs.kaspresso.compose.support)
254
+
255
+ testImplementation(libs.kotlinx.coroutines.test)
256
+
151
257
}
152
258
259
+
153
260
tasks.withType<Test > {
154
261
// Configure Jacoco for each tests
155
262
configure<JacocoTaskExtension > {
@@ -158,8 +265,8 @@ tasks.withType<Test> {
158
265
}
159
266
}
160
267
161
- tasks.register(" jacocoTestReport" , JacocoReport ::class ) {
162
- mustRunAfter(" testDebugUnitTest" , " connectedDebugAndroidTest" )
268
+ tasks.register(" jacocoTestReport" ,JacocoReport ::class ) {
269
+ mustRunAfter(" testDebugUnitTest" ," connectedDebugAndroidTest" )
163
270
164
271
reports {
165
272
xml.required = true
@@ -174,16 +281,15 @@ tasks.register("jacocoTestReport", JacocoReport::class) {
174
281
" **/*Test*.*" ,
175
282
" android/**/*.*" ,
176
283
)
177
-
178
- val debugTree = fileTree(" ${project.layout.buildDirectory.get()} /tmp/kotlin-classes/debug" ) {
284
+ val debugTree = fileTree(" ${project.buildDir} /tmp/kotlin-classes/debug" ) {
179
285
exclude(fileFilter)
180
286
}
287
+ val mainSrc = " ${project.projectDir} /src/main/java"
181
288
182
- val mainSrc = " ${project.layout.projectDirectory} /src/main/java"
183
289
sourceDirectories.setFrom(files(mainSrc))
184
290
classDirectories.setFrom(files(debugTree))
185
- executionData.setFrom(fileTree(project.layout.buildDirectory.get() ) {
291
+ executionData.setFrom(fileTree(project.buildDir ) {
186
292
include(" outputs/unit_test_code_coverage/debugUnitTest/testDebugUnitTest.exec" )
187
293
include(" outputs/code_coverage/debugAndroidTest/connected/*/coverage.ec" )
188
294
})
189
- }
295
+ }
0 commit comments