xref: /aosp_15_r20/external/jetpack-camera-app/feature/preview/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.library)
19     alias(libs.plugins.kotlin.android)
20     alias(libs.plugins.kotlin.kapt)
21     alias(libs.plugins.dagger.hilt.android)
22 }
23 
<lambda>null24 android {
25     namespace = "com.google.jetpackcamera.feature.preview"
26     compileSdk = libs.versions.compileSdk.get().toInt()
27     compileSdkPreview = libs.versions.compileSdkPreview.get()
28 
29     defaultConfig {
30         minSdk = libs.versions.minSdk.get().toInt()
31         testOptions.targetSdk = libs.versions.targetSdk.get().toInt()
32         lint.targetSdk = libs.versions.targetSdk.get().toInt()
33 
34         testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
35     }
36 
37     flavorDimensions += "flavor"
38     productFlavors {
39         create("stable") {
40             dimension = "flavor"
41             isDefault = true
42         }
43 
44         create("preview") {
45             dimension = "flavor"
46             targetSdkPreview = libs.versions.targetSdkPreview.get()
47         }
48     }
49 
50     compileOptions {
51         sourceCompatibility = JavaVersion.VERSION_17
52         targetCompatibility = JavaVersion.VERSION_17
53     }
54     kotlin {
55         jvmToolchain(17)
56     }
57     buildFeatures {
58         buildConfig = true
59         compose = true
60     }
61     composeOptions {
62         kotlinCompilerExtensionVersion = libs.versions.composeCompiler.get()
63     }
64 
65     @Suppress("UnstableApiUsage")
66     testOptions {
67         unitTests {
68             isReturnDefaultValues = true
69             isIncludeAndroidResources = true
70         }
71         managedDevices {
72             localDevices {
73                 create("pixel2Api28") {
74                     device = "Pixel 2"
75                     apiLevel = 28
76                 }
77                 create("pixel8Api34") {
78                     device = "Pixel 8"
79                     apiLevel = 34
80                     systemImageSource = "aosp_atd"
81                 }
82             }
83         }
84     }
85 
86     kotlinOptions {
87         freeCompilerArgs += "-Xcontext-receivers"
88     }
89 }
90 
<lambda>null91 dependencies {
92     // Reflect
93     implementation(libs.kotlin.reflect)
94     // Compose
95     val composeBom = platform(libs.compose.bom)
96     implementation(composeBom)
97     androidTestImplementation(composeBom)
98 
99     // Compose - Material Design 3
100     implementation(libs.compose.material3)
101     implementation(libs.compose.material.icons.extended)
102 
103     // Compose - Android Studio Preview support
104     implementation(libs.compose.ui.tooling.preview)
105     debugImplementation(libs.compose.ui.tooling)
106 
107     // Compose - Integration with ViewModels with Navigation and Hilt
108     implementation(libs.hilt.navigation.compose)
109 
110     // Compose - Lifecycle utilities
111     implementation(libs.androidx.lifecycle.viewmodel.compose)
112     implementation(libs.androidx.lifecycle.runtime.compose)
113 
114     // Compose - Testing
115     androidTestImplementation(libs.compose.junit)
116     debugImplementation(libs.compose.test.manifest)
117     // noinspection TestManifestGradleConfiguration: required for release build unit tests
118     testImplementation(libs.compose.test.manifest)
119     testImplementation(libs.compose.junit)
120 
121     // Testing
122     testImplementation(libs.junit)
123     testImplementation(libs.truth)
124     testImplementation(libs.mockito.core)
125     testImplementation(libs.kotlinx.coroutines.test)
126     testImplementation(libs.robolectric)
127     debugImplementation(libs.androidx.test.monitor)
128     implementation(libs.androidx.junit)
129     androidTestImplementation(libs.androidx.junit)
130     androidTestImplementation(libs.androidx.espresso.core)
131 
132     // Futures
133     implementation(libs.futures.ktx)
134 
135     // CameraX
136     implementation(libs.camera.core)
137     implementation(libs.camera.viewfinder.compose)
138 
139     // Hilt
140     implementation(libs.dagger.hilt.android)
141     kapt(libs.dagger.hilt.compiler)
142 
143     //Tracing
144     implementation(libs.androidx.tracing)
145 
146     implementation(libs.kotlinx.atomicfu)
147 
148     // Project dependencies
149     implementation(project(":data:settings"))
150     implementation(project(":core:camera"))
151     implementation(project(":core:common"))
152     testImplementation(project(":core:common"))
153 }
154 
155 // Allow references to generated code
156 kapt {
157     correctErrorTypes = true
158 }