Skip to content

Commit 35f0a9f

Browse files
committed
Enable for Kotlin Gradle dsl.
Additionally migrate to using a version catalog to simplify dependency management.
1 parent b5a821d commit 35f0a9f

File tree

6 files changed

+86
-65
lines changed

6 files changed

+86
-65
lines changed

build.gradle

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,9 @@ import com.google.firebase.gradle.plugins.license.LicenseResolverPlugin
1616
import com.google.firebase.gradle.MultiProjectReleasePlugin
1717

1818
buildscript {
19-
ext.kotlinVersion = '1.7.10'
20-
ext.coroutinesVersion = '1.6.4'
19+
// TODO: remove once all sdks have migrated to version catalog
20+
ext.kotlinVersion = libs.versions.kotlin.get()
21+
ext.coroutinesVersion = libs.versions.coroutines.get()
2122

2223
repositories {
2324
google()
@@ -47,13 +48,12 @@ apply from: 'sdkProperties.gradle'
4748
apply from: "gradle/errorProne.gradle"
4849

4950
ext {
50-
playServicesVersion = '16.0.1'
51-
supportAnnotationsVersion = '28.0.0'
52-
googleTruthVersion = '1.1.2'
53-
grpcVersion = '1.50.2'
54-
robolectricVersion = '4.9'
55-
protocVersion = '3.17.3'
56-
javaliteVersion = '3.17.3'
51+
// TODO: remove once all sdks have migrated to version catalog
52+
googleTruthVersion = libs.versions.truth.get()
53+
grpcVersion = libs.versions.grpc.get()
54+
robolectricVersion = libs.versions.robolectric.get()
55+
protocVersion = libs.versions.protoc.get()
56+
javaliteVersion = libs.versions.javalite.get()
5757
}
5858

5959
apply plugin: com.google.firebase.gradle.plugins.publish.PublishingPlugin

firebase-common/ktx/ktx.gradle

Lines changed: 0 additions & 55 deletions
This file was deleted.

firebase-common/ktx/ktx.gradle.kts

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
// Copyright 2019 Google LLC
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
plugins {
16+
id("firebase-library")
17+
id("kotlin-android")
18+
}
19+
20+
firebaseLibrary {
21+
releaseWith(project(":firebase-common"))
22+
}
23+
24+
android {
25+
val targetSdkVersion : Int by rootProject
26+
val minSdkVersion : Int by rootProject
27+
compileSdk = targetSdkVersion
28+
defaultConfig {
29+
minSdk = minSdkVersion
30+
targetSdk = targetSdkVersion
31+
}
32+
testOptions.unitTests.isIncludeAndroidResources = true
33+
}
34+
35+
dependencies {
36+
implementation(libs.kotlin.stdlib)
37+
38+
implementation(project(":firebase-annotations"))
39+
implementation(project(":firebase-common"))
40+
implementation(project(":firebase-components"))
41+
implementation(libs.androidx.annotation)
42+
43+
// We"re exposing this library as a transitive dependency so developers can
44+
// get Kotlin Coroutines support out-of-the-box for methods that return a Task
45+
api(libs.kotlin.coroutines.tasks)
46+
47+
testImplementation(libs.robolectric)
48+
testImplementation(libs.junit)
49+
testImplementation(libs.truth)
50+
testImplementation(libs.androidx.test.core)
51+
testImplementation(libs.kotlin.coroutines.test)
52+
}

gradle/libs.versions.toml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
[versions]
2+
coroutines = '1.6.4'
3+
grpc = "1.50.2"
4+
kotlin = "1.7.10"
5+
robolectric = "4.9"
6+
truth = "1.1.2"
7+
protoc = "3.17.3"
8+
javalite = "3.17.3"
9+
10+
[libraries]
11+
kotlin-stdlib = { module = "org.jetbrains.kotlin:kotlin-stdlib", version.ref = "kotlin" }
12+
kotlin-coroutines-tasks = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-play-services", version.ref = "coroutines" }
13+
kotlin-coroutines-test = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-test", version.ref = "coroutines" }
14+
15+
robolectric = {module = "org.robolectric:robolectric", version.ref = "robolectric" }
16+
truth = { module = "com.google.truth:truth", version.ref = "truth"}
17+
18+
androidx-annotation = { module = "androidx.annotation:annotation", version = "1.5.0" }
19+
androidx-test-core = { module = "androidx.test:core", version = "1.5.0" }
20+
junit = { module = "junit:junit", version = "4.13.2" }

gradle/projectSettings.gradle

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,9 @@ ext {
2929

3030
/** Recursively renames build scripts to ${project.name}.gradle. */
3131
renameBuildScripts = {ProjectDescriptor project ->
32-
project.buildFileName = project.parent ? "${project.name}.gradle" : 'build.gradle'
32+
def ktsFile = "${project.name}.gradle.kts"
33+
def projectFile = new File(project.projectDir, ktsFile).exists() ? ktsFile : "${project.name}.gradle"
34+
project.buildFileName = project.parent ? projectFile : 'build.gradle'
3335

3436
project.children.each {
3537
renameBuildScripts(it)

settings.gradle

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414

1515
rootProject.name = 'com.google.firebase'
1616

17+
enableFeaturePreview("VERSION_CATALOGS")
18+
1719
//Note: do not add subprojects to this file. Instead add them to subprojects.gradle
1820

1921
apply from: 'gradle/projectSettings.gradle'

0 commit comments

Comments
 (0)