Skip to content

Enable for Kotlin Gradle dsl. #4392

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Dec 2, 2022
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,9 @@ import com.google.firebase.gradle.plugins.license.LicenseResolverPlugin
import com.google.firebase.gradle.MultiProjectReleasePlugin

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

repositories {
google()
Expand Down Expand Up @@ -47,13 +48,12 @@ apply from: 'sdkProperties.gradle'
apply from: "gradle/errorProne.gradle"

ext {
playServicesVersion = '16.0.1'
supportAnnotationsVersion = '28.0.0'
googleTruthVersion = '1.1.2'
grpcVersion = '1.50.2'
robolectricVersion = '4.9'
protocVersion = '3.17.3'
javaliteVersion = '3.17.3'
// TODO: remove once all sdks have migrated to version catalog
googleTruthVersion = libs.versions.truth.get()
grpcVersion = libs.versions.grpc.get()
robolectricVersion = libs.versions.robolectric.get()
protocVersion = libs.versions.protoc.get()
javaliteVersion = libs.versions.javalite.get()
}

apply plugin: com.google.firebase.gradle.plugins.publish.PublishingPlugin
Expand Down
55 changes: 0 additions & 55 deletions firebase-common/ktx/ktx.gradle

This file was deleted.

60 changes: 60 additions & 0 deletions firebase-common/ktx/ktx.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
// Copyright 2019 Google LLC
//
// 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.

plugins {
id("firebase-library")
id("kotlin-android")
}

firebaseLibrary {
releaseWith(project(":firebase-common"))
}

android {
val targetSdkVersion : Int by rootProject
val minSdkVersion : Int by rootProject
compileSdk = targetSdkVersion
defaultConfig {
minSdk = minSdkVersion
targetSdk = targetSdkVersion
}
sourceSets {
getByName("main") {
java.srcDirs("src/main/kotlin")
}
getByName("test") {
java.srcDirs("src/test/kotlin")
}
}
testOptions.unitTests.isIncludeAndroidResources = true
}

dependencies {
implementation(libs.kotlin.stdlib)

implementation(project(":firebase-annotations"))
implementation(project(":firebase-common"))
implementation(project(":firebase-components"))
implementation(libs.androidx.annotation)

// We"re exposing this library as a transitive dependency so developers can
// get Kotlin Coroutines support out-of-the-box for methods that return a Task
api(libs.kotlin.coroutines.tasks)

testImplementation(libs.robolectric)
testImplementation(libs.junit)
testImplementation(libs.truth)
testImplementation(libs.androidx.test.core)
testImplementation(libs.kotlin.coroutines.test)
}
20 changes: 20 additions & 0 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
[versions]
coroutines = '1.6.4'
grpc = "1.50.2"
kotlin = "1.7.10"
robolectric = "4.9"
truth = "1.1.2"
protoc = "3.17.3"
javalite = "3.17.3"

[libraries]
kotlin-stdlib = { module = "org.jetbrains.kotlin:kotlin-stdlib", version.ref = "kotlin" }
kotlin-coroutines-tasks = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-play-services", version.ref = "coroutines" }
kotlin-coroutines-test = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-test", version.ref = "coroutines" }

robolectric = {module = "org.robolectric:robolectric", version.ref = "robolectric" }
truth = { module = "com.google.truth:truth", version.ref = "truth"}

androidx-annotation = { module = "androidx.annotation:annotation", version = "1.5.0" }
androidx-test-core = { module = "androidx.test:core", version = "1.5.0" }
junit = { module = "junit:junit", version = "4.13.2" }
4 changes: 3 additions & 1 deletion gradle/projectSettings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@ ext {

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

project.children.each {
renameBuildScripts(it)
Expand Down
2 changes: 2 additions & 0 deletions settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@

rootProject.name = 'com.google.firebase'

enableFeaturePreview("VERSION_CATALOGS")

//Note: do not add subprojects to this file. Instead add them to subprojects.gradle

apply from: 'gradle/projectSettings.gradle'
Expand Down