xref: /aosp_15_r20/frameworks/base/packages/SettingsLib/Spa/spa/build.gradle.kts (revision d57664e9bc4670b3ecf6748a746a57c557b6bc9e)
1 /*
2  * Copyright (C) 2023 The Android Open Source Project
3  *
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 
<lambda>null17 plugins {
18     alias(libs.plugins.android.library)
19     alias(libs.plugins.compose.compiler)
20     alias(libs.plugins.kotlin.android)
21     jacoco
22 }
23 
24 val jetpackComposeVersion: String? by extra
25 
<lambda>null26 android {
27     namespace = "com.android.settingslib.spa"
28 
29     defaultConfig {
30         testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
31     }
32 
33     sourceSets {
34         sourceSets.getByName("main") {
35             kotlin.setSrcDirs(listOf("src"))
36             res.setSrcDirs(listOf("res"))
37             manifest.srcFile("AndroidManifest.xml")
38         }
39         sourceSets.getByName("androidTest") {
40             kotlin.setSrcDirs(listOf("../tests/src"))
41             res.setSrcDirs(listOf("../tests/res"))
42             manifest.srcFile("../tests/AndroidManifest.xml")
43         }
44     }
45     buildTypes {
46         getByName("debug") {
47             enableAndroidTestCoverage = true
48         }
49     }
50 }
51 
<lambda>null52 dependencies {
53     api(project(":SettingsLibColor"))
54     api("androidx.appcompat:appcompat:1.7.0")
55     api("androidx.compose.material3:material3:1.4.0-alpha04")
56     api("androidx.compose.material:material-icons-extended")
57     api("androidx.compose.runtime:runtime-livedata:$jetpackComposeVersion")
58     api("androidx.compose.ui:ui-tooling-preview:$jetpackComposeVersion")
59     api("androidx.graphics:graphics-shapes-android:1.0.1")
60     api("androidx.lifecycle:lifecycle-livedata-ktx")
61     api("androidx.lifecycle:lifecycle-runtime-compose")
62     api("androidx.navigation:navigation-compose:2.9.0-alpha03")
63     api("com.github.PhilJay:MPAndroidChart:v3.1.0-alpha")
64     api("com.google.android.material:material:1.13.0-alpha08")
65     debugApi("androidx.compose.ui:ui-tooling:$jetpackComposeVersion")
66     implementation("com.airbnb.android:lottie-compose:6.4.0")
67 
68     androidTestImplementation(project(":testutils"))
69     androidTestImplementation(libs.dexmaker.mockito)
70 }
71 
<lambda>null72 tasks.register<JacocoReport>("coverageReport") {
73     group = "Reporting"
74     description = "Generate Jacoco coverage reports after running tests."
75     dependsOn("connectedDebugAndroidTest")
76     sourceDirectories.setFrom(files("src"))
77     classDirectories.setFrom(
78         fileTree(layout.buildDirectory.dir("tmp/kotlin-classes/debug")) {
79             setExcludes(
80                 listOf(
81                     "com/android/settingslib/spa/debug/**",
82 
83                     // Excludes files forked from AndroidX.
84                     "com/android/settingslib/spa/widget/scaffold/CustomizedAppBar*",
85 
86                     // Excludes files forked from Accompanist.
87                     "com/android/settingslib/spa/framework/compose/DrawablePainter*",
88 
89                     // Excludes inline functions, which is not covered in Jacoco reports.
90                     "com/android/settingslib/spa/framework/util/Collections*",
91                     "com/android/settingslib/spa/framework/util/Flows*",
92 
93                     // Excludes debug functions
94                     "com/android/settingslib/spa/framework/compose/TimeMeasurer*",
95                 )
96             )
97         }
98     )
99     executionData.setFrom(
100         fileTree(layout.buildDirectory.dir("outputs/code_coverage/debugAndroidTest/connected"))
101     )
102 }
103