xref: /aosp_15_r20/external/jetpack-camera-app/benchmark/build.gradle.kts (revision 7e7863dab8204bb545ead586e736dea632e06846)
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.test)
19     alias(libs.plugins.kotlin.android)
20 }
21 
<lambda>null22 android {
23     namespace = "com.google.jetpackcamera.benchmark"
24     compileSdk = libs.versions.compileSdk.get().toInt()
25     compileSdkPreview = libs.versions.compileSdkPreview.get()
26 
27     compileOptions {
28         sourceCompatibility = JavaVersion.VERSION_1_8
29         targetCompatibility = JavaVersion.VERSION_1_8
30     }
31 
32     kotlinOptions {
33         jvmTarget = "1.8"
34     }
35 
36     defaultConfig {
37         //Our app has a minSDK of 21, but in order for the benchmark tool to function, it must be 23
38         minSdk = 23
39         targetSdk = libs.versions.targetSdk.get().toInt()
40 
41         // allows the benchmark to be run on an emulator
42         testInstrumentationRunnerArguments["androidx.benchmark.suppressErrors"] =
43             "EMULATOR,LOW-BATTERY,NOT-PROFILEABLE"
44 
45         testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
46     }
47 
48     buildTypes {
49         // This benchmark buildType is used for benchmarking, and should function like your
50         // release build (for example, with minification on). It"s signed with a debug key
51         // for easy local/CI testing.
52         create("benchmark") {
53             isDebuggable = true
54             signingConfig = getByName("debug").signingConfig
55             matchingFallbacks += listOf("release")
56         }
57     }
58 
59     flavorDimensions += "flavor"
60     productFlavors {
61         create("stable") {
62             dimension = "flavor"
63         }
64 
65         create("preview") {
66             dimension = "flavor"
67             targetSdkPreview = libs.versions.targetSdkPreview.get()
68         }
69     }
70 
71     targetProjectPath = ":app"
72     // required for benchmark:
73     // self instrumentation required for the tests to be able to compile, start, or kill the app
74     // ensures test and app processes are separate
75     // see https://source.android.com/docs/core/tests/development/instr-self-e2e
76     experimentalProperties["android.experimental.self-instrumenting"] = true
77 }
78 
<lambda>null79 dependencies {
80     implementation(libs.androidx.junit)
81     implementation(libs.androidx.benchmark.macro.junit4)
82 }
83 
84 androidComponents {
<lambda>null85     beforeVariants(selector().all()) {
86         it.enable = it.buildType == "benchmark"
87     }
88 }