| /* |
| * Copyright (C) 2017 The Android Open Source Project |
| * |
| * Licensed under the Apache License, Version 2.0 (the "License"); |
| * you may not use this file except in compliance with the License. |
| * You may obtain a copy of the License at |
| * |
| * http://www.apache.org/licenses/LICENSE-2.0 |
| * |
| * Unless required by applicable law or agreed to in writing, software |
| * distributed under the License is distributed on an "AS IS" BASIS, |
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| * See the License for the specific language governing permissions and |
| * limitations under the License. |
| */ |
| // TO debug processor, run: |
| //./gradlew :r:in:k:clean :r:in:k:cC --no-daemon |
| // -Dorg.gradle.debug=true |
| // -Dkotlin.compiler.execution.strategy="in-process" |
| |
| import com.google.devtools.ksp.gradle.KspTask |
| |
| plugins { |
| id("AndroidXPlugin") |
| id("com.android.application") |
| id("kotlin-android") |
| // both ksp and kapt are applied. each run in their own variant. |
| id("com.google.devtools.ksp") |
| id("kotlin-kapt") |
| id("androidx.room") |
| } |
| android { |
| buildFeatures { |
| buildConfig = true |
| } |
| |
| flavorDimensions "processorConfiguration" |
| productFlavors { |
| withKapt { |
| dimension "processorConfiguration" |
| } |
| withKspGenJava { |
| dimension "processorConfiguration" |
| } |
| withKspGenKotlin { |
| dimension "processorConfiguration" |
| } |
| } |
| namespace = "androidx.room.integration.kotlintestapp" |
| } |
| |
| dependencies { |
| implementation(project(":room:room-common")) |
| implementation(project(":room:room-runtime")) |
| implementation(project(":room:room-paging")) |
| implementation(project(":paging:paging-runtime")) |
| implementation(project(":paging:paging-guava")) |
| implementation("androidx.arch.core:core-runtime:2.2.0") |
| implementation("androidx.lifecycle:lifecycle-livedata-ktx:2.6.1") |
| implementation(libs.kotlinStdlib) |
| implementation(libs.kotlinCoroutinesAndroid) |
| kspAndroidTestWithKspGenJava(project(":room:room-compiler")) |
| kspAndroidTestWithKspGenKotlin(project(":room:room-compiler")) |
| kaptAndroidTestWithKapt(project(":room:room-compiler")) |
| androidTestImplementation("androidx.arch.core:core-runtime:2.2.0") |
| androidTestImplementation("androidx.lifecycle:lifecycle-livedata-ktx:2.6.1") |
| androidTestImplementation(libs.testExtJunit) |
| androidTestImplementation(libs.testCore) |
| androidTestImplementation(libs.testRunner) { |
| exclude module: "support-annotations" |
| exclude module: "hamcrest-core" |
| } |
| androidTestImplementation(libs.espressoCore, { |
| exclude group: "com.android.support", module: "support-annotations" |
| exclude module: "hamcrest-core" |
| }) |
| androidTestImplementation(project(":kruth:kruth")) |
| androidTestImplementation(libs.kotlinTest) |
| androidTestImplementation(project(":room:room-guava")) |
| androidTestImplementation(project(":room:room-testing")) |
| androidTestImplementation(project(":room:room-paging-guava")) |
| androidTestImplementation(project(":room:room-paging-rxjava2")) |
| androidTestImplementation(project(":room:room-paging-rxjava3")) |
| // we need latest guava android because room-paging-guava's guava-android gets override by |
| // its kotlinx-coroutines-guava dependency's guava-jre version |
| androidTestImplementation(libs.guavaAndroid) |
| androidTestImplementation(project(":room:room-rxjava2")) |
| androidTestImplementation(project(":room:room-rxjava3")) |
| androidTestImplementation(project(":room:room-ktx")) |
| androidTestImplementation(project(":internal-testutils-common")) |
| androidTestImplementation(project(":paging:paging-runtime")) |
| androidTestImplementation(project(":paging:paging-guava")) |
| androidTestImplementation(project(":paging:paging-rxjava2")) |
| androidTestImplementation(project(":paging:paging-rxjava3")) |
| androidTestImplementation("androidx.arch.core:core-testing:2.2.0") |
| androidTestImplementation("androidx.lifecycle:lifecycle-runtime-testing:2.6.1") |
| androidTestImplementation(libs.rxjava2) |
| androidTestImplementation(libs.kotlinCoroutinesTest) |
| androidTestImplementation("androidx.collection:collection") |
| androidTestImplementation(project(":sqlite:sqlite-bundled")) |
| } |
| |
| room { |
| schemaDirectory( |
| "withKapt", |
| layout.projectDirectory.dir("schemas") |
| ) |
| schemaDirectory( |
| "withKspGenJava", |
| layout.projectDirectory.dir("schemas-ksp") |
| ) |
| schemaDirectory( |
| "withKspGenKotlin", |
| layout.projectDirectory.dir("schemas-ksp") |
| ) |
| } |
| |
| class RoomGenKotlinArgProvider implements CommandLineArgumentProvider { |
| |
| @Input |
| Provider<Boolean> generateKotlin; |
| |
| RoomGenKotlinArgProvider(Provider<Boolean> generateKotlin) { |
| this.generateKotlin = generateKotlin |
| } |
| |
| @Override |
| Iterable<String> asArguments() { |
| return ["room.generateKotlin=" + generateKotlin.get()] |
| } |
| } |
| |
| // KSP does not support argument per flavor so for per flavor options we use flavor named tasks. |
| // See https://github.com/google/ksp/issues/861. |
| tasks.withType(KspTask).configureEach { kspTask -> |
| kspTask.commandLineArgumentProviders.add( |
| new RoomGenKotlinArgProvider( |
| provider { kspTask.name.contains("GenKotlin") } |
| ) |
| ) |
| } |
| |
| ksp { |
| useKsp2 = true |
| } |