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