|
| 1 | +import org.jetbrains.kotlin.gradle.plugin.KotlinSourceSetTree |
| 2 | + |
| 3 | +/* |
| 4 | + * Copyright (c) 2020 GitLive Ltd. Use of this source code is governed by the Apache 2.0 license. |
| 5 | + */ |
| 6 | + |
| 7 | +version = project.property("firebase-common-internal.version") as String |
| 8 | + |
| 9 | +plugins { |
| 10 | + id("com.android.library") |
| 11 | + kotlin("multiplatform") |
| 12 | + kotlin("plugin.serialization") |
| 13 | +} |
| 14 | + |
| 15 | +android { |
| 16 | + val minSdkVersion: Int by project |
| 17 | + val compileSdkVersion: Int by project |
| 18 | + |
| 19 | + compileSdk = compileSdkVersion |
| 20 | + namespace = "dev.gitlive.firebase.common.internal" |
| 21 | + defaultConfig { |
| 22 | + minSdk = minSdkVersion |
| 23 | + testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" |
| 24 | + } |
| 25 | + |
| 26 | + compileOptions { |
| 27 | + sourceCompatibility = JavaVersion.VERSION_11 |
| 28 | + targetCompatibility = JavaVersion.VERSION_11 |
| 29 | + } |
| 30 | + |
| 31 | + testOptions { |
| 32 | + unitTests.apply { |
| 33 | + isIncludeAndroidResources = true |
| 34 | + } |
| 35 | + } |
| 36 | + |
| 37 | + packaging { |
| 38 | + resources.pickFirsts.add("META-INF/kotlinx-serialization-core.kotlin_module") |
| 39 | + resources.pickFirsts.add("META-INF/AL2.0") |
| 40 | + resources.pickFirsts.add("META-INF/LGPL2.1") |
| 41 | + } |
| 42 | + lint { |
| 43 | + abortOnError = false |
| 44 | + } |
| 45 | +} |
| 46 | + |
| 47 | +kotlin { |
| 48 | + |
| 49 | + targets.configureEach { |
| 50 | + compilations.configureEach { |
| 51 | + kotlinOptions.freeCompilerArgs += "-Xexpect-actual-classes" |
| 52 | + } |
| 53 | + } |
| 54 | + |
| 55 | + @Suppress("OPT_IN_USAGE") |
| 56 | + androidTarget { |
| 57 | + instrumentedTestVariant.sourceSetTree.set(KotlinSourceSetTree.test) |
| 58 | + unitTestVariant.sourceSetTree.set(KotlinSourceSetTree.test) |
| 59 | + publishAllLibraryVariants() |
| 60 | + compilations.configureEach { |
| 61 | + kotlinOptions { |
| 62 | + jvmTarget = "11" |
| 63 | + } |
| 64 | + } |
| 65 | + } |
| 66 | + |
| 67 | + jvm { |
| 68 | + compilations.getByName("main") { |
| 69 | + kotlinOptions { |
| 70 | + jvmTarget = "17" |
| 71 | + } |
| 72 | + } |
| 73 | + compilations.getByName("test") { |
| 74 | + kotlinOptions { |
| 75 | + jvmTarget = "17" |
| 76 | + } |
| 77 | + } |
| 78 | + } |
| 79 | + |
| 80 | + val supportIosTarget = project.property("skipIosTarget") != "true" |
| 81 | + |
| 82 | + if (supportIosTarget) { |
| 83 | + iosArm64() |
| 84 | + iosX64() |
| 85 | + iosSimulatorArm64() |
| 86 | + } |
| 87 | + |
| 88 | + js(IR) { |
| 89 | + useCommonJs() |
| 90 | + nodejs { |
| 91 | + testTask( |
| 92 | + Action { |
| 93 | + useKarma { |
| 94 | + useChromeHeadless() |
| 95 | + } |
| 96 | + } |
| 97 | + ) |
| 98 | + } |
| 99 | + browser { |
| 100 | + testTask( |
| 101 | + Action { |
| 102 | + useKarma { |
| 103 | + useChromeHeadless() |
| 104 | + } |
| 105 | + } |
| 106 | + ) |
| 107 | + } |
| 108 | + } |
| 109 | + |
| 110 | + sourceSets { |
| 111 | + all { |
| 112 | + languageSettings.apply { |
| 113 | + val apiVersion: String by project |
| 114 | + val languageVersion: String by project |
| 115 | + this.apiVersion = apiVersion |
| 116 | + this.languageVersion = languageVersion |
| 117 | + progressiveMode = true |
| 118 | + optIn("kotlinx.coroutines.ExperimentalCoroutinesApi") |
| 119 | + optIn("kotlinx.serialization.ExperimentalSerializationApi") |
| 120 | + optIn("kotlinx.serialization.InternalSerializationApi") |
| 121 | + } |
| 122 | + } |
| 123 | + |
| 124 | + getByName("commonMain") { |
| 125 | + val serializationVersion: String by project |
| 126 | + |
| 127 | + dependencies { |
| 128 | + implementation(project(":firebase-common")) |
| 129 | + api("org.jetbrains.kotlinx:kotlinx-serialization-core:$serializationVersion") |
| 130 | + } |
| 131 | + } |
| 132 | + |
| 133 | + getByName("commonTest") { |
| 134 | + dependencies { |
| 135 | + implementation(project(":test-utils")) |
| 136 | + } |
| 137 | + } |
| 138 | + |
| 139 | + getByName("androidMain") { |
| 140 | + dependencies { |
| 141 | + api("com.google.firebase:firebase-common-ktx") |
| 142 | + } |
| 143 | + } |
| 144 | + |
| 145 | + getByName("jsMain") { |
| 146 | + dependencies { |
| 147 | + api(npm("firebase", "10.6.0")) |
| 148 | + } |
| 149 | + } |
| 150 | + |
| 151 | + getByName("jvmMain") { |
| 152 | + kotlin.srcDir("src/androidMain/kotlin") |
| 153 | + } |
| 154 | + |
| 155 | + getByName("jvmTest") { |
| 156 | + dependencies { |
| 157 | + implementation(kotlin("test-junit")) |
| 158 | + } |
| 159 | + kotlin.srcDir("src/androidAndroidTest/kotlin") |
| 160 | + } |
| 161 | + } |
| 162 | +} |
| 163 | + |
| 164 | +if (project.property("firebase-common.skipIosTests") == "true") { |
| 165 | + tasks.forEach { |
| 166 | + if (it.name.contains("ios", true) && it.name.contains("test", true)) { it.enabled = false } |
| 167 | + } |
| 168 | +} |
| 169 | + |
| 170 | +if (project.property("firebase-common.skipJsTests") == "true") { |
| 171 | + tasks.forEach { |
| 172 | + if (it.name.contains("js", true) && it.name.contains("test", true)) { it.enabled = false } |
| 173 | + } |
| 174 | +} |
| 175 | + |
| 176 | +signing { |
| 177 | + val signingKey: String? by project |
| 178 | + val signingPassword: String? by project |
| 179 | + useInMemoryPgpKeys(signingKey, signingPassword) |
| 180 | + sign(publishing.publications) |
| 181 | +} |
| 182 | + |
0 commit comments