Florina Muntenescu | 34f575b | 2017-07-17 10:38:50 +0100 | [diff] [blame] | 1 | /* |
| 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 Boyar | 1f8acf7 | 2018-02-08 13:05:00 -0800 | [diff] [blame] | 16 | // 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 Lam | c351bfc | 2020-03-11 20:32:42 -0700 | [diff] [blame] | 20 | |
| 21 | import org.jetbrains.kotlin.gradle.tasks.KotlinCompile |
| 22 | |
Aurimas Liutikas | 238e480 | 2017-12-14 10:52:11 -0800 | [diff] [blame] | 23 | plugins { |
Aurimas Liutikas | 21ff5d1 | 2018-08-15 15:33:13 -0700 | [diff] [blame] | 24 | id("AndroidXPlugin") |
| 25 | id("com.android.application") |
Aurimas Liutikas | 238e480 | 2017-12-14 10:52:11 -0800 | [diff] [blame] | 26 | id("kotlin-android") |
Yigit Boyar | 315ae40 | 2021-07-14 22:07:56 -0700 | [diff] [blame] | 27 | // both ksp and kapt are applied. each run in their own variant. |
| 28 | id("com.google.devtools.ksp") |
| 29 | id("kotlin-kapt") |
Yigit Boyar | 23758df | 2020-12-16 18:47:29 -0800 | [diff] [blame] | 30 | } |
Florina Muntenescu | 34f575b | 2017-07-17 10:38:50 +0100 | [diff] [blame] | 31 | android { |
Yigit Boyar | af110fe | 2021-01-14 22:53:42 -0800 | [diff] [blame] | 32 | buildFeatures { |
| 33 | buildConfig = true |
| 34 | } |
Florina Muntenescu | 34f575b | 2017-07-17 10:38:50 +0100 | [diff] [blame] | 35 | defaultConfig { |
Yigit Boyar | 04b0474 | 2021-02-26 12:04:07 -0800 | [diff] [blame] | 36 | multiDexEnabled true |
Florina Muntenescu | 34f575b | 2017-07-17 10:38:50 +0100 | [diff] [blame] | 37 | javaCompileOptions { |
| 38 | annotationProcessorOptions { |
Yigit Boyar | 60b74ae | 2020-03-10 17:02:50 -0700 | [diff] [blame] | 39 | arguments = [ |
Yigit Boyar | 315ae40 | 2021-07-14 22:07:56 -0700 | [diff] [blame] | 40 | "room.schemaLocation" : "$projectDir/schemas".toString() |
Yigit Boyar | 60b74ae | 2020-03-10 17:02:50 -0700 | [diff] [blame] | 41 | ] |
Florina Muntenescu | 34f575b | 2017-07-17 10:38:50 +0100 | [diff] [blame] | 42 | } |
| 43 | } |
| 44 | } |
Dustin Lam | c351bfc | 2020-03-11 20:32:42 -0700 | [diff] [blame] | 45 | |
Florina Muntenescu | 34f575b | 2017-07-17 10:38:50 +0100 | [diff] [blame] | 46 | sourceSets { |
Yigit Boyar | 315ae40 | 2021-07-14 22:07:56 -0700 | [diff] [blame] | 47 | androidTestWithKapt.assets.srcDirs += files("$projectDir/schemas".toString()) |
| 48 | androidTestWithKsp.assets.srcDirs += files("$projectDir/schemas-ksp".toString()) |
Florina Muntenescu | 34f575b | 2017-07-17 10:38:50 +0100 | [diff] [blame] | 49 | } |
Yigit Boyar | 7110304 | 2020-04-06 17:28:21 -0700 | [diff] [blame] | 50 | |
Jeff Gaston | ff3f1b2 | 2020-08-04 11:24:37 -0400 | [diff] [blame] | 51 | flavorDimensions "processorConfiguration" |
| 52 | productFlavors { |
Yigit Boyar | 315ae40 | 2021-07-14 22:07:56 -0700 | [diff] [blame] | 53 | withKapt { |
Jeff Gaston | ff3f1b2 | 2020-08-04 11:24:37 -0400 | [diff] [blame] | 54 | dimension "processorConfiguration" |
| 55 | javaCompileOptions { |
| 56 | annotationProcessorOptions { |
| 57 | arguments = [ |
| 58 | "room.schemaLocation" : "$projectDir/schemas".toString(), |
Jeff Gaston | ff3f1b2 | 2020-08-04 11:24:37 -0400 | [diff] [blame] | 59 | ] |
| 60 | } |
| 61 | } |
| 62 | } |
Yigit Boyar | 315ae40 | 2021-07-14 22:07:56 -0700 | [diff] [blame] | 63 | withKsp { |
Jeff Gaston | ff3f1b2 | 2020-08-04 11:24:37 -0400 | [diff] [blame] | 64 | dimension "processorConfiguration" |
Jeff Gaston | ff3f1b2 | 2020-08-04 11:24:37 -0400 | [diff] [blame] | 65 | } |
| 66 | } |
Aurimas Liutikas | dcfa035 | 2022-03-14 16:05:33 -0700 | [diff] [blame] | 67 | namespace "androidx.room.integration.kotlintestapp" |
Florina Muntenescu | 34f575b | 2017-07-17 10:38:50 +0100 | [diff] [blame] | 68 | } |
| 69 | |
| 70 | dependencies { |
Alan Viverette | 6c56334 | 2018-03-08 18:02:39 -0500 | [diff] [blame] | 71 | implementation(project(":room:room-common")) |
Alan Viverette | 6c56334 | 2018-03-08 18:02:39 -0500 | [diff] [blame] | 72 | implementation(project(":room:room-runtime")) |
Clara Fok | 22eccb9 | 2021-06-15 16:32:01 -0700 | [diff] [blame] | 73 | implementation(project(":room:room-paging")) |
Dustin Lam | 1b2b8e2 | 2020-11-19 00:39:04 +0000 | [diff] [blame] | 74 | implementation(projectOrArtifact(":arch:core:core-runtime")) |
Yigit Boyar | a755f33 | 2020-05-30 19:14:46 -0700 | [diff] [blame] | 75 | implementation(projectOrArtifact(":lifecycle:lifecycle-livedata")) |
Yigit Boyar | af110fe | 2021-01-14 22:53:42 -0800 | [diff] [blame] | 76 | implementation(projectOrArtifact(":lifecycle:lifecycle-livedata-ktx")) |
Aurimas Liutikas | 1a0e7b1 | 2021-05-04 12:55:40 -0700 | [diff] [blame] | 77 | implementation(libs.kotlinStdlib) |
| 78 | implementation(libs.kotlinCoroutinesAndroid) |
| 79 | implementation(libs.multidex) |
Yigit Boyar | 562a37d | 2020-03-16 13:00:36 -0700 | [diff] [blame] | 80 | // depend on the shadowed version so that it tests with the shipped artifact |
Yigit Boyar | 23758df | 2020-12-16 18:47:29 -0800 | [diff] [blame] | 81 | // this is a temporary attribute until KSP and AndroidX plugin supports variants. |
Yigit Boyar | 315ae40 | 2021-07-14 22:07:56 -0700 | [diff] [blame] | 82 | kspAndroidTestWithKsp( |
| 83 | project(path: ":room:room-compiler", configuration: "shadowAndImplementation") |
| 84 | ) |
| 85 | kaptAndroidTestWithKapt( |
| 86 | project(path: ":room:room-compiler", configuration: "shadowAndImplementation") |
| 87 | ) |
Aurimas Liutikas | cb841c5 | 2021-04-01 14:14:10 -0700 | [diff] [blame] | 88 | androidTestImplementation(projectOrArtifact(":lifecycle:lifecycle-livedata-ktx")) |
Aurimas Liutikas | 1a0e7b1 | 2021-05-04 12:55:40 -0700 | [diff] [blame] | 89 | androidTestImplementation(libs.testExtJunit) |
| 90 | androidTestImplementation(libs.testCore) |
| 91 | androidTestImplementation(libs.testRunner) { |
Jim Sproch | 9e38b4f | 2021-01-06 14:21:06 -0800 | [diff] [blame] | 92 | exclude module: "support-annotations" |
| 93 | exclude module: "hamcrest-core" |
Florina Muntenescu | 34f575b | 2017-07-17 10:38:50 +0100 | [diff] [blame] | 94 | } |
Aurimas Liutikas | 1a0e7b1 | 2021-05-04 12:55:40 -0700 | [diff] [blame] | 95 | androidTestImplementation(libs.espressoCore, { |
Jim Sproch | 9e38b4f | 2021-01-06 14:21:06 -0800 | [diff] [blame] | 96 | exclude group: "com.android.support", module: "support-annotations" |
Florina Muntenescu | 34f575b | 2017-07-17 10:38:50 +0100 | [diff] [blame] | 97 | exclude module: "hamcrest-core" |
| 98 | }) |
Aurimas Liutikas | 1a0e7b1 | 2021-05-04 12:55:40 -0700 | [diff] [blame] | 99 | androidTestImplementation(libs.truth) |
Clara Fok | 22eccb9 | 2021-06-15 16:32:01 -0700 | [diff] [blame] | 100 | androidTestImplementation(libs.kotlinTest) |
Jim Sproch | 9e38b4f | 2021-01-06 14:21:06 -0800 | [diff] [blame] | 101 | androidTestImplementation(project(":room:room-guava")) |
| 102 | androidTestImplementation(project(":room:room-testing")) |
Clara Fok | 76e8c1e | 2022-04-28 17:05:24 -0700 | [diff] [blame] | 103 | androidTestImplementation(project(":room:room-paging-guava")) |
clarafok | d1ba579 | 2022-05-13 16:09:09 -0700 | [diff] [blame] | 104 | androidTestImplementation(project(":room:room-paging-rxjava2")) |
clarafok | c7b01e9 | 2022-05-12 15:28:45 -0700 | [diff] [blame] | 105 | androidTestImplementation(project(":room:room-paging-rxjava3")) |
Clara Fok | 76e8c1e | 2022-04-28 17:05:24 -0700 | [diff] [blame] | 106 | // 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 Sproch | 9e38b4f | 2021-01-06 14:21:06 -0800 | [diff] [blame] | 109 | androidTestImplementation(project(":room:room-rxjava2")) |
Yigit Boyar | af110fe | 2021-01-14 22:53:42 -0800 | [diff] [blame] | 110 | androidTestImplementation(project(":room:room-rxjava3")) |
Daniel Santiago Rivera | 1fc1960 | 2019-02-27 15:48:32 -0800 | [diff] [blame] | 111 | androidTestImplementation(project(":room:room-ktx")) |
Clara Fok | 583863d | 2021-08-18 18:28:43 -0700 | [diff] [blame] | 112 | androidTestImplementation(project(":internal-testutils-common")) |
Ian Lake | 005a920 | 2019-09-26 16:17:25 -0700 | [diff] [blame] | 113 | androidTestImplementation("androidx.arch.core:core-testing:2.0.1") |
Dustin Lam | cd9288e | 2022-04-21 15:33:51 -0700 | [diff] [blame] | 114 | androidTestImplementation("androidx.paging:paging-runtime:3.1.1") |
Dustin Lam | 45c4978 | 2022-08-22 19:11:59 +0000 | [diff] [blame^] | 115 | androidTestImplementation(projectOrArtifact(":lifecycle:lifecycle-runtime-testing")) |
Aurimas Liutikas | 1a0e7b1 | 2021-05-04 12:55:40 -0700 | [diff] [blame] | 116 | androidTestImplementation(libs.rxjava2) |
| 117 | testImplementation(libs.mockitoCore) |
Florina Muntenescu | 34f575b | 2017-07-17 10:38:50 +0100 | [diff] [blame] | 118 | } |
| 119 | |
Yigit Boyar | 315ae40 | 2021-07-14 22:07:56 -0700 | [diff] [blame] | 120 | // KSP does not support argument per flavor so we set it to global instead. |
| 121 | ksp { |
| 122 | arg("room.schemaLocation","$projectDir/schemas-ksp".toString()) |
Yigit Boyar | 3f9bc79 | 2021-03-24 16:33:44 -0700 | [diff] [blame] | 123 | } |
| 124 | |
Dustin Lam | c351bfc | 2020-03-11 20:32:42 -0700 | [diff] [blame] | 125 | // Allow usage of Kotlin's @OptIn. |
| 126 | tasks.withType(KotlinCompile).configureEach { |
| 127 | kotlinOptions { |
Jim Sproch | bcbd33a | 2022-01-12 14:45:37 -0800 | [diff] [blame] | 128 | freeCompilerArgs += ["-opt-in=kotlin.RequiresOptIn"] |
Dustin Lam | c351bfc | 2020-03-11 20:32:42 -0700 | [diff] [blame] | 129 | } |
| 130 | } |