blob: 2f2ac2467a6cc33ba6e992af78101bd80a794136 [file] [log] [blame]
Chaohui Wang4c18b352023-06-08 16:11:22 +08001/*
Chaohui Wang26521472023-11-03 23:19:57 +08002 * Copyright (C) 2023 The Android Open Source Project
Chaohui Wang4c18b352023-06-08 16:11:22 +08003 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17plugins {
Chaohui Wanga180c482023-06-11 02:26:18 +080018 alias(libs.plugins.android.library)
19 alias(libs.plugins.kotlin.android)
Chaohui Wang4c18b352023-06-08 16:11:22 +080020 jacoco
21}
22
23val jetpackComposeVersion: String? by extra
24
25android {
26 namespace = "com.android.settingslib.spa"
27
28 defaultConfig {
29 testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
30 }
31
32 sourceSets {
33 sourceSets.getByName("main") {
34 kotlin.setSrcDirs(listOf("src"))
35 res.setSrcDirs(listOf("res"))
36 manifest.srcFile("AndroidManifest.xml")
37 }
38 sourceSets.getByName("androidTest") {
39 kotlin.setSrcDirs(listOf("../tests/src"))
40 res.setSrcDirs(listOf("../tests/res"))
41 manifest.srcFile("../tests/AndroidManifest.xml")
42 }
43 }
44 buildFeatures {
45 compose = true
46 }
47 buildTypes {
48 getByName("debug") {
49 enableAndroidTestCoverage = true
50 }
51 }
52}
53
54dependencies {
Chaohui Wangb9b2b172023-08-14 19:44:10 +080055 api(project(":SettingsLibColor"))
Chaohui Wang6603c872023-07-20 17:08:08 +080056 api("androidx.appcompat:appcompat:1.7.0-alpha03")
Chaohui Wang4c18b352023-06-08 16:11:22 +080057 api("androidx.slice:slice-builders:1.1.0-alpha02")
58 api("androidx.slice:slice-core:1.1.0-alpha02")
59 api("androidx.slice:slice-view:1.1.0-alpha02")
Chaohui Wangfcc24ec2024-03-21 14:02:36 +080060 api("androidx.compose.material3:material3:1.3.0-alpha03")
Chaohui Wang4c18b352023-06-08 16:11:22 +080061 api("androidx.compose.material:material-icons-extended:$jetpackComposeVersion")
62 api("androidx.compose.runtime:runtime-livedata:$jetpackComposeVersion")
63 api("androidx.compose.ui:ui-tooling-preview:$jetpackComposeVersion")
64 api("androidx.lifecycle:lifecycle-livedata-ktx")
65 api("androidx.lifecycle:lifecycle-runtime-compose")
Chaohui Wangfcc24ec2024-03-21 14:02:36 +080066 api("androidx.navigation:navigation-compose:2.8.0-alpha05")
Chaohui Wang4c18b352023-06-08 16:11:22 +080067 api("com.github.PhilJay:MPAndroidChart:v3.1.0-alpha")
68 api("com.google.android.material:material:1.7.0-alpha03")
69 debugApi("androidx.compose.ui:ui-tooling:$jetpackComposeVersion")
70 implementation("com.airbnb.android:lottie-compose:5.2.0")
71
72 androidTestImplementation(project(":testutils"))
Chaohui Wanga180c482023-06-11 02:26:18 +080073 androidTestImplementation(libs.dexmaker.mockito)
Chaohui Wang4c18b352023-06-08 16:11:22 +080074}
75
76tasks.register<JacocoReport>("coverageReport") {
77 group = "Reporting"
78 description = "Generate Jacoco coverage reports after running tests."
79 dependsOn("connectedDebugAndroidTest")
80 sourceDirectories.setFrom(files("src"))
81 classDirectories.setFrom(
82 fileTree(layout.buildDirectory.dir("tmp/kotlin-classes/debug")) {
83 setExcludes(
84 listOf(
85 "com/android/settingslib/spa/debug/**",
86
87 // Excludes files forked from AndroidX.
88 "com/android/settingslib/spa/widget/scaffold/CustomizedAppBar*",
89 "com/android/settingslib/spa/widget/scaffold/TopAppBarColors*",
90
91 // Excludes files forked from Accompanist.
92 "com/android/settingslib/spa/framework/compose/DrawablePainter*",
93
94 // Excludes inline functions, which is not covered in Jacoco reports.
95 "com/android/settingslib/spa/framework/util/Collections*",
96 "com/android/settingslib/spa/framework/util/Flows*",
97
98 // Excludes debug functions
99 "com/android/settingslib/spa/framework/compose/TimeMeasurer*",
100
101 // Excludes slice demo presenter & provider
102 "com/android/settingslib/spa/slice/presenter/Demo*",
103 "com/android/settingslib/spa/slice/provider/Demo*",
104 )
105 )
106 }
107 )
108 executionData.setFrom(
109 fileTree(layout.buildDirectory.dir("outputs/code_coverage/debugAndroidTest/connected"))
110 )
111}