|
| 1 | +/* |
| 2 | + * Copyright 2024 Google LLC |
| 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 | + |
| 17 | +@file:Suppress("UnstableApiUsage") |
| 18 | + |
| 19 | +import org.jetbrains.kotlin.gradle.tasks.KotlinCompile |
| 20 | + |
| 21 | +plugins { |
| 22 | + id("firebase-library") |
| 23 | + id("kotlin-android") |
| 24 | + alias(libs.plugins.kotlinx.serialization) |
| 25 | +} |
| 26 | + |
| 27 | +firebaseLibrary { |
| 28 | + testLab.enabled = false |
| 29 | + publishJavadoc = true |
| 30 | + releaseNotes { |
| 31 | + name.set("{{firebase_ai}}") |
| 32 | + versionName.set("ai") |
| 33 | + hasKTX.set(false) |
| 34 | + } |
| 35 | +} |
| 36 | + |
| 37 | +android { |
| 38 | + val targetSdkVersion: Int by rootProject |
| 39 | + |
| 40 | + namespace = "com.google.firebase.ai" |
| 41 | + compileSdk = 34 |
| 42 | + defaultConfig { |
| 43 | + minSdk = 21 |
| 44 | + consumerProguardFiles("consumer-rules.pro") |
| 45 | + multiDexEnabled = true |
| 46 | + testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" |
| 47 | + } |
| 48 | + buildTypes { |
| 49 | + release { |
| 50 | + isMinifyEnabled = false |
| 51 | + proguardFiles(getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro") |
| 52 | + } |
| 53 | + } |
| 54 | + compileOptions { |
| 55 | + sourceCompatibility = JavaVersion.VERSION_1_8 |
| 56 | + targetCompatibility = JavaVersion.VERSION_1_8 |
| 57 | + } |
| 58 | + kotlinOptions { jvmTarget = "1.8" } |
| 59 | + testOptions { |
| 60 | + targetSdk = targetSdkVersion |
| 61 | + unitTests { |
| 62 | + isIncludeAndroidResources = true |
| 63 | + isReturnDefaultValues = true |
| 64 | + } |
| 65 | + } |
| 66 | + lint { |
| 67 | + targetSdk = targetSdkVersion |
| 68 | + baseline = file("lint-baseline.xml") |
| 69 | + } |
| 70 | + sourceSets { getByName("test").java.srcDirs("src/testUtil") } |
| 71 | +} |
| 72 | + |
| 73 | +// Enable Kotlin "Explicit API Mode". This causes the Kotlin compiler to fail if any |
| 74 | +// classes, methods, or properties have implicit `public` visibility. This check helps |
| 75 | +// avoid accidentally leaking elements into the public API, requiring that any public |
| 76 | +// element be explicitly declared as `public`. |
| 77 | +// https://github.com/Kotlin/KEEP/blob/master/proposals/explicit-api-mode.md |
| 78 | +// https://chao2zhang.medium.com/explicit-api-mode-for-kotlin-on-android-b8264fdd76d1 |
| 79 | +tasks.withType<KotlinCompile>().all { |
| 80 | + if (!name.contains("test", ignoreCase = true)) { |
| 81 | + if (!kotlinOptions.freeCompilerArgs.contains("-Xexplicit-api=strict")) { |
| 82 | + kotlinOptions.freeCompilerArgs += "-Xexplicit-api=strict" |
| 83 | + } |
| 84 | + } |
| 85 | +} |
| 86 | + |
| 87 | +dependencies { |
| 88 | + implementation(libs.ktor.client.okhttp) |
| 89 | + implementation(libs.ktor.client.core) |
| 90 | + implementation(libs.ktor.client.websockets) |
| 91 | + implementation(libs.ktor.client.content.negotiation) |
| 92 | + implementation(libs.ktor.serialization.kotlinx.json) |
| 93 | + implementation(libs.ktor.client.logging) |
| 94 | + |
| 95 | + api("com.google.firebase:firebase-common:21.0.0") |
| 96 | + implementation("com.google.firebase:firebase-components:18.0.0") |
| 97 | + implementation("com.google.firebase:firebase-annotations:16.2.0") |
| 98 | + implementation("com.google.firebase:firebase-appcheck-interop:17.1.0") |
| 99 | + implementation(libs.androidx.annotation) |
| 100 | + implementation(libs.kotlinx.serialization.json) |
| 101 | + implementation(libs.androidx.core.ktx) |
| 102 | + implementation(libs.slf4j.nop) |
| 103 | + implementation(libs.kotlinx.coroutines.android) |
| 104 | + implementation(libs.kotlinx.coroutines.reactive) |
| 105 | + implementation(libs.reactive.streams) |
| 106 | + implementation("com.google.guava:listenablefuture:1.0") |
| 107 | + implementation("androidx.concurrent:concurrent-futures:1.2.0") |
| 108 | + implementation("androidx.concurrent:concurrent-futures-ktx:1.2.0") |
| 109 | + implementation("com.google.firebase:firebase-auth-interop:18.0.0") |
| 110 | + |
| 111 | + testImplementation(libs.kotest.assertions.core) |
| 112 | + testImplementation(libs.kotest.assertions) |
| 113 | + testImplementation(libs.kotest.assertions.json) |
| 114 | + testImplementation(libs.ktor.client.okhttp) |
| 115 | + testImplementation(libs.ktor.client.mock) |
| 116 | + testImplementation(libs.org.json) |
| 117 | + testImplementation(libs.androidx.test.junit) |
| 118 | + testImplementation(libs.androidx.test.runner) |
| 119 | + testImplementation(libs.junit) |
| 120 | + testImplementation(libs.kotlin.coroutines.test) |
| 121 | + testImplementation(libs.robolectric) |
| 122 | + testImplementation(libs.truth) |
| 123 | + testImplementation(libs.mockito.core) |
| 124 | + |
| 125 | + androidTestImplementation(libs.androidx.espresso.core) |
| 126 | + androidTestImplementation(libs.androidx.test.junit) |
| 127 | + androidTestImplementation(libs.androidx.test.runner) |
| 128 | + androidTestImplementation(libs.truth) |
| 129 | +} |
0 commit comments