Chaohui Wang | 4c18b35 | 2023-06-08 16:11:22 +0800 | [diff] [blame] | 1 | /* |
Chaohui Wang | 2652147 | 2023-11-03 23:19:57 +0800 | [diff] [blame] | 2 | * Copyright (C) 2023 The Android Open Source Project |
Chaohui Wang | 4c18b35 | 2023-06-08 16:11:22 +0800 | [diff] [blame] | 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 | |
| 17 | plugins { |
Chaohui Wang | a180c48 | 2023-06-11 02:26:18 +0800 | [diff] [blame] | 18 | alias(libs.plugins.android.library) |
| 19 | alias(libs.plugins.kotlin.android) |
Chaohui Wang | 4c18b35 | 2023-06-08 16:11:22 +0800 | [diff] [blame] | 20 | jacoco |
| 21 | } |
| 22 | |
| 23 | val jetpackComposeVersion: String? by extra |
| 24 | |
| 25 | android { |
| 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 | |
| 54 | dependencies { |
Chaohui Wang | b9b2b17 | 2023-08-14 19:44:10 +0800 | [diff] [blame] | 55 | api(project(":SettingsLibColor")) |
Chaohui Wang | 3d4a7e1 | 2024-07-18 15:13:45 +0800 | [diff] [blame] | 56 | api("androidx.appcompat:appcompat:1.7.0") |
Yuchen | 5826bdb | 2024-10-14 09:10:49 +0000 | [diff] [blame] | 57 | api("androidx.compose.material3:material3:1.4.0-alpha01") |
Chaohui Wang | 4c18b35 | 2023-06-08 16:11:22 +0800 | [diff] [blame] | 58 | api("androidx.compose.material:material-icons-extended:$jetpackComposeVersion") |
| 59 | api("androidx.compose.runtime:runtime-livedata:$jetpackComposeVersion") |
| 60 | api("androidx.compose.ui:ui-tooling-preview:$jetpackComposeVersion") |
Chaohui Wang | a2f0ea0 | 2024-09-26 11:15:32 +0800 | [diff] [blame] | 61 | api("androidx.graphics:graphics-shapes-android:1.0.1") |
Chaohui Wang | 4c18b35 | 2023-06-08 16:11:22 +0800 | [diff] [blame] | 62 | api("androidx.lifecycle:lifecycle-livedata-ktx") |
| 63 | api("androidx.lifecycle:lifecycle-runtime-compose") |
Chaohui Wang | 0a868bd | 2024-09-20 14:34:32 +0800 | [diff] [blame] | 64 | api("androidx.navigation:navigation-compose:2.8.1") |
Chaohui Wang | 4c18b35 | 2023-06-08 16:11:22 +0800 | [diff] [blame] | 65 | api("com.github.PhilJay:MPAndroidChart:v3.1.0-alpha") |
Chaohui Wang | a2f0ea0 | 2024-09-26 11:15:32 +0800 | [diff] [blame] | 66 | api("com.google.android.material:material:1.12.0") |
Chaohui Wang | 4c18b35 | 2023-06-08 16:11:22 +0800 | [diff] [blame] | 67 | debugApi("androidx.compose.ui:ui-tooling:$jetpackComposeVersion") |
Chaohui Wang | 0fbfd81 | 2024-06-14 14:00:10 +0800 | [diff] [blame] | 68 | implementation("com.airbnb.android:lottie-compose:6.4.0") |
Chaohui Wang | 4c18b35 | 2023-06-08 16:11:22 +0800 | [diff] [blame] | 69 | |
| 70 | androidTestImplementation(project(":testutils")) |
Chaohui Wang | a180c48 | 2023-06-11 02:26:18 +0800 | [diff] [blame] | 71 | androidTestImplementation(libs.dexmaker.mockito) |
Chaohui Wang | 4c18b35 | 2023-06-08 16:11:22 +0800 | [diff] [blame] | 72 | } |
| 73 | |
| 74 | tasks.register<JacocoReport>("coverageReport") { |
| 75 | group = "Reporting" |
| 76 | description = "Generate Jacoco coverage reports after running tests." |
| 77 | dependsOn("connectedDebugAndroidTest") |
| 78 | sourceDirectories.setFrom(files("src")) |
| 79 | classDirectories.setFrom( |
| 80 | fileTree(layout.buildDirectory.dir("tmp/kotlin-classes/debug")) { |
| 81 | setExcludes( |
| 82 | listOf( |
| 83 | "com/android/settingslib/spa/debug/**", |
| 84 | |
| 85 | // Excludes files forked from AndroidX. |
| 86 | "com/android/settingslib/spa/widget/scaffold/CustomizedAppBar*", |
Chaohui Wang | 4c18b35 | 2023-06-08 16:11:22 +0800 | [diff] [blame] | 87 | |
| 88 | // Excludes files forked from Accompanist. |
| 89 | "com/android/settingslib/spa/framework/compose/DrawablePainter*", |
| 90 | |
| 91 | // Excludes inline functions, which is not covered in Jacoco reports. |
| 92 | "com/android/settingslib/spa/framework/util/Collections*", |
| 93 | "com/android/settingslib/spa/framework/util/Flows*", |
| 94 | |
| 95 | // Excludes debug functions |
| 96 | "com/android/settingslib/spa/framework/compose/TimeMeasurer*", |
Chaohui Wang | 4c18b35 | 2023-06-08 16:11:22 +0800 | [diff] [blame] | 97 | ) |
| 98 | ) |
| 99 | } |
| 100 | ) |
| 101 | executionData.setFrom( |
| 102 | fileTree(layout.buildDirectory.dir("outputs/code_coverage/debugAndroidTest/connected")) |
| 103 | ) |
| 104 | } |