blob: a88e0f27c232c4698709bf8023c1d4157ff01cf9 [file] [log] [blame]
Florina Muntenescu34f575b2017-07-17 10:38:50 +01001/*
2 * Copyright (C) 2017 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 */
Yigit Boyar1f8acf72018-02-08 13:05:00 -080016// TO debug processor, run:
17//./gradlew :r:in:k:clean :r:in:k:cC --no-daemon
18// -Dorg.gradle.debug=true
19// -Dkotlin.compiler.execution.strategy="in-process"
Dustin Lamc351bfc2020-03-11 20:32:42 -070020
21import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
22
Aurimas Liutikas238e4802017-12-14 10:52:11 -080023plugins {
Aurimas Liutikas21ff5d12018-08-15 15:33:13 -070024 id("AndroidXPlugin")
25 id("com.android.application")
Aurimas Liutikas238e4802017-12-14 10:52:11 -080026 id("kotlin-android")
Yigit Boyar315ae402021-07-14 22:07:56 -070027 // both ksp and kapt are applied. each run in their own variant.
28 id("com.google.devtools.ksp")
29 id("kotlin-kapt")
Yigit Boyar23758df2020-12-16 18:47:29 -080030}
Florina Muntenescu34f575b2017-07-17 10:38:50 +010031android {
Yigit Boyaraf110fe2021-01-14 22:53:42 -080032 buildFeatures {
33 buildConfig = true
34 }
Florina Muntenescu34f575b2017-07-17 10:38:50 +010035 defaultConfig {
Yigit Boyar04b04742021-02-26 12:04:07 -080036 multiDexEnabled true
Florina Muntenescu34f575b2017-07-17 10:38:50 +010037 javaCompileOptions {
38 annotationProcessorOptions {
Yigit Boyar60b74ae2020-03-10 17:02:50 -070039 arguments = [
Yigit Boyar315ae402021-07-14 22:07:56 -070040 "room.schemaLocation" : "$projectDir/schemas".toString()
Yigit Boyar60b74ae2020-03-10 17:02:50 -070041 ]
Florina Muntenescu34f575b2017-07-17 10:38:50 +010042 }
43 }
44 }
Dustin Lamc351bfc2020-03-11 20:32:42 -070045
Florina Muntenescu34f575b2017-07-17 10:38:50 +010046 sourceSets {
Yigit Boyar315ae402021-07-14 22:07:56 -070047 androidTestWithKapt.assets.srcDirs += files("$projectDir/schemas".toString())
48 androidTestWithKsp.assets.srcDirs += files("$projectDir/schemas-ksp".toString())
Florina Muntenescu34f575b2017-07-17 10:38:50 +010049 }
Yigit Boyar71103042020-04-06 17:28:21 -070050
Jeff Gastonff3f1b22020-08-04 11:24:37 -040051 flavorDimensions "processorConfiguration"
52 productFlavors {
Yigit Boyar315ae402021-07-14 22:07:56 -070053 withKapt {
Jeff Gastonff3f1b22020-08-04 11:24:37 -040054 dimension "processorConfiguration"
55 javaCompileOptions {
56 annotationProcessorOptions {
57 arguments = [
58 "room.schemaLocation" : "$projectDir/schemas".toString(),
Jeff Gastonff3f1b22020-08-04 11:24:37 -040059 ]
60 }
61 }
62 }
Yigit Boyar315ae402021-07-14 22:07:56 -070063 withKsp {
Jeff Gastonff3f1b22020-08-04 11:24:37 -040064 dimension "processorConfiguration"
Jeff Gastonff3f1b22020-08-04 11:24:37 -040065 }
66 }
Aurimas Liutikasdcfa0352022-03-14 16:05:33 -070067 namespace "androidx.room.integration.kotlintestapp"
Florina Muntenescu34f575b2017-07-17 10:38:50 +010068}
69
70dependencies {
Alan Viverette6c563342018-03-08 18:02:39 -050071 implementation(project(":room:room-common"))
Alan Viverette6c563342018-03-08 18:02:39 -050072 implementation(project(":room:room-runtime"))
Clara Fok22eccb92021-06-15 16:32:01 -070073 implementation(project(":room:room-paging"))
Dustin Lam1b2b8e22020-11-19 00:39:04 +000074 implementation(projectOrArtifact(":arch:core:core-runtime"))
Yigit Boyara755f332020-05-30 19:14:46 -070075 implementation(projectOrArtifact(":lifecycle:lifecycle-livedata"))
Yigit Boyaraf110fe2021-01-14 22:53:42 -080076 implementation(projectOrArtifact(":lifecycle:lifecycle-livedata-ktx"))
Aurimas Liutikas1a0e7b12021-05-04 12:55:40 -070077 implementation(libs.kotlinStdlib)
78 implementation(libs.kotlinCoroutinesAndroid)
79 implementation(libs.multidex)
Yigit Boyar562a37d2020-03-16 13:00:36 -070080 // depend on the shadowed version so that it tests with the shipped artifact
Yigit Boyar23758df2020-12-16 18:47:29 -080081 // this is a temporary attribute until KSP and AndroidX plugin supports variants.
Yigit Boyar315ae402021-07-14 22:07:56 -070082 kspAndroidTestWithKsp(
83 project(path: ":room:room-compiler", configuration: "shadowAndImplementation")
84 )
85 kaptAndroidTestWithKapt(
86 project(path: ":room:room-compiler", configuration: "shadowAndImplementation")
87 )
Aurimas Liutikascb841c52021-04-01 14:14:10 -070088 androidTestImplementation(projectOrArtifact(":lifecycle:lifecycle-livedata-ktx"))
Aurimas Liutikas1a0e7b12021-05-04 12:55:40 -070089 androidTestImplementation(libs.testExtJunit)
90 androidTestImplementation(libs.testCore)
91 androidTestImplementation(libs.testRunner) {
Jim Sproch9e38b4f2021-01-06 14:21:06 -080092 exclude module: "support-annotations"
93 exclude module: "hamcrest-core"
Florina Muntenescu34f575b2017-07-17 10:38:50 +010094 }
Aurimas Liutikas1a0e7b12021-05-04 12:55:40 -070095 androidTestImplementation(libs.espressoCore, {
Jim Sproch9e38b4f2021-01-06 14:21:06 -080096 exclude group: "com.android.support", module: "support-annotations"
Florina Muntenescu34f575b2017-07-17 10:38:50 +010097 exclude module: "hamcrest-core"
98 })
Aurimas Liutikas1a0e7b12021-05-04 12:55:40 -070099 androidTestImplementation(libs.truth)
Clara Fok22eccb92021-06-15 16:32:01 -0700100 androidTestImplementation(libs.kotlinTest)
Jim Sproch9e38b4f2021-01-06 14:21:06 -0800101 androidTestImplementation(project(":room:room-guava"))
102 androidTestImplementation(project(":room:room-testing"))
Clara Fok76e8c1e2022-04-28 17:05:24 -0700103 androidTestImplementation(project(":room:room-paging-guava"))
clarafokd1ba5792022-05-13 16:09:09 -0700104 androidTestImplementation(project(":room:room-paging-rxjava2"))
clarafokc7b01e92022-05-12 15:28:45 -0700105 androidTestImplementation(project(":room:room-paging-rxjava3"))
Clara Fok76e8c1e2022-04-28 17:05:24 -0700106 // we need latest guava android because room-paging-guava's guava-android gets override by
107 // its kotlinx-coroutines-guava dependency's guava-jre version
108 androidTestImplementation(libs.guavaAndroid)
Jim Sproch9e38b4f2021-01-06 14:21:06 -0800109 androidTestImplementation(project(":room:room-rxjava2"))
Yigit Boyaraf110fe2021-01-14 22:53:42 -0800110 androidTestImplementation(project(":room:room-rxjava3"))
Daniel Santiago Rivera1fc19602019-02-27 15:48:32 -0800111 androidTestImplementation(project(":room:room-ktx"))
Clara Fok583863d2021-08-18 18:28:43 -0700112 androidTestImplementation(project(":internal-testutils-common"))
Ian Lake005a9202019-09-26 16:17:25 -0700113 androidTestImplementation("androidx.arch.core:core-testing:2.0.1")
Dustin Lamcd9288e2022-04-21 15:33:51 -0700114 androidTestImplementation("androidx.paging:paging-runtime:3.1.1")
Dustin Lam45c49782022-08-22 19:11:59 +0000115 androidTestImplementation(projectOrArtifact(":lifecycle:lifecycle-runtime-testing"))
Aurimas Liutikas1a0e7b12021-05-04 12:55:40 -0700116 androidTestImplementation(libs.rxjava2)
117 testImplementation(libs.mockitoCore)
Florina Muntenescu34f575b2017-07-17 10:38:50 +0100118}
119
Yigit Boyar315ae402021-07-14 22:07:56 -0700120// KSP does not support argument per flavor so we set it to global instead.
121ksp {
122 arg("room.schemaLocation","$projectDir/schemas-ksp".toString())
Yigit Boyar3f9bc792021-03-24 16:33:44 -0700123}
124
Dustin Lamc351bfc2020-03-11 20:32:42 -0700125// Allow usage of Kotlin's @OptIn.
126tasks.withType(KotlinCompile).configureEach {
127 kotlinOptions {
Jim Sprochbcbd33a2022-01-12 14:45:37 -0800128 freeCompilerArgs += ["-opt-in=kotlin.RequiresOptIn"]
Dustin Lamc351bfc2020-03-11 20:32:42 -0700129 }
130}