From 5ba3ea96f3c85dc6345fc2510d3b0a1db6735d8d Mon Sep 17 00:00:00 2001 From: joao freitas Date: Tue, 26 Mar 2024 08:37:47 -0300 Subject: [PATCH] feature: add crashlytics --- app/build.gradle.kts | 1 + app/google-services.json | 67 +++++++++++++++++++ build-logic/convention/build.gradle.kts | 5 ++ ...roidApplicationFirebaseConventionPlugin.kt | 52 ++++++++++++++ build.gradle.kts | 5 +- gradle/libs.versions.toml | 11 ++- 6 files changed, 138 insertions(+), 3 deletions(-) create mode 100644 app/google-services.json create mode 100644 build-logic/convention/src/main/kotlin/AndroidApplicationFirebaseConventionPlugin.kt diff --git a/app/build.gradle.kts b/app/build.gradle.kts index 0bb542d..461d797 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -3,6 +3,7 @@ import com.br.weightcontrol.WeiBuildType plugins { alias(libs.plugins.weightcontrol.android.application) alias(libs.plugins.weightcontrol.android.application.compose) + alias(libs.plugins.weightcontrol.android.application.firebase) id("com.google.android.libraries.mapsplatform.secrets-gradle-plugin") } diff --git a/app/google-services.json b/app/google-services.json new file mode 100644 index 0000000..c08e540 --- /dev/null +++ b/app/google-services.json @@ -0,0 +1,67 @@ +{ + "project_info": { + "project_number": "389953825500", + "project_id": "weightcontrol-dd344", + "storage_bucket": "weightcontrol-dd344.appspot.com" + }, + "client": [ + { + "client_info": { + "mobilesdk_app_id": "1:389953825500:android:6a7dc615fcfdff28426219", + "android_client_info": { + "package_name": "br.com.weightcontrol" + } + }, + "oauth_client": [], + "api_key": [ + { + "current_key": "AIzaSyDuNi2IPv0SdbjTyLZPWdgAD1vY2QoN8kw" + } + ], + "services": { + "appinvite_service": { + "other_platform_oauth_client": [] + } + } + }, + { + "client_info": { + "mobilesdk_app_id": "1:389953825500:android:50008286cc4fcd96426219", + "android_client_info": { + "package_name": "com.br.weightcontrol" + } + }, + "oauth_client": [], + "api_key": [ + { + "current_key": "AIzaSyDuNi2IPv0SdbjTyLZPWdgAD1vY2QoN8kw" + } + ], + "services": { + "appinvite_service": { + "other_platform_oauth_client": [] + } + } + }, + { + "client_info": { + "mobilesdk_app_id": "1:389953825500:android:8c9be728ed134302426219", + "android_client_info": { + "package_name": "com.br.weightcontrol.debug" + } + }, + "oauth_client": [], + "api_key": [ + { + "current_key": "AIzaSyDuNi2IPv0SdbjTyLZPWdgAD1vY2QoN8kw" + } + ], + "services": { + "appinvite_service": { + "other_platform_oauth_client": [] + } + } + } + ], + "configuration_version": "1" +} \ No newline at end of file diff --git a/build-logic/convention/build.gradle.kts b/build-logic/convention/build.gradle.kts index 9e84027..fdd8307 100644 --- a/build-logic/convention/build.gradle.kts +++ b/build-logic/convention/build.gradle.kts @@ -24,6 +24,7 @@ repositories { dependencies { compileOnly(libs.android.gradlePlugin) + compileOnly(libs.firebase.crashlytics.gradlePlugin) compileOnly(libs.kotlin.gradlePlugin) compileOnly(libs.ksp.gradlePlugin) } @@ -54,5 +55,9 @@ gradlePlugin { id = "weightcontrol.jvm.library" implementationClass = "JvmLibraryConventionPlugin" } + register("androidFirebase") { + id = "weightcontrol.android.application.firebase" + implementationClass = "AndroidApplicationFirebaseConventionPlugin" + } } } \ No newline at end of file diff --git a/build-logic/convention/src/main/kotlin/AndroidApplicationFirebaseConventionPlugin.kt b/build-logic/convention/src/main/kotlin/AndroidApplicationFirebaseConventionPlugin.kt new file mode 100644 index 0000000..4526e4c --- /dev/null +++ b/build-logic/convention/src/main/kotlin/AndroidApplicationFirebaseConventionPlugin.kt @@ -0,0 +1,52 @@ +/* + * Copyright 2022 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 + * + * https://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. + */ + +import com.android.build.api.dsl.ApplicationExtension +import com.br.weightcontrol.libs +import com.google.firebase.crashlytics.buildtools.gradle.CrashlyticsExtension + +import org.gradle.api.Plugin +import org.gradle.api.Project +import org.gradle.kotlin.dsl.configure +import org.gradle.kotlin.dsl.dependencies + +class AndroidApplicationFirebaseConventionPlugin : Plugin { + override fun apply(target: Project) { + with(target) { + with(pluginManager) { + apply("com.google.gms.google-services") + apply("com.google.firebase.crashlytics") + } + + dependencies { + val bom = libs.findLibrary("firebase-bom").get() + add("implementation", platform(bom)) + "implementation"(libs.findLibrary("firebase.crashlytics").get()) + } + + extensions.configure { + buildTypes.configureEach { + // Disable the Crashlytics mapping file upload. This feature should only be + // enabled if a Firebase backend is available and configured in + // google-services.json. + configure { + mappingFileUploadEnabled = false + } + } + } + } + } +} diff --git a/build.gradle.kts b/build.gradle.kts index be65f6f..a687f77 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -23,10 +23,11 @@ buildscript { plugins { alias(libs.plugins.android.application) apply false + alias(libs.plugins.android.library) apply false + alias(libs.plugins.firebase.crashlytics) apply false + alias(libs.plugins.gms) apply false alias(libs.plugins.kotlin.jvm) apply false alias(libs.plugins.kotlin.serialization) apply false alias(libs.plugins.ksp) apply false alias(libs.plugins.secrets) apply false - id("com.android.library") version "7.4.1" apply false - id("org.jetbrains.kotlin.android") version "1.8.20" apply false } diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index a01ff5f..fa768ad 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -14,6 +14,9 @@ androidxLifecycle = "2.7.0" androidxNavigation = "2.7.4" androidxTestCore = "1.5.0" chart = "1.6.4" +firebaseBom = "32.4.0" +firebaseCrashlyticsPlugin = "2.9.9" +gmsPlugin = "4.4.0" junit4 = "4.13.2" kotlin = "1.9.21" koinAndroid = "3.5.3" @@ -59,6 +62,8 @@ androidx-test-core = { group = "androidx.test", name = "core", version.ref = "an chart-core = { group = "com.patrykandpatrick.vico", name = "core", version.ref = "chart" } chart-compose = { group = "com.patrykandpatrick.vico", name = "compose", version.ref = "chart" } chart-compose-m3 = { group = "com.patrykandpatrick.vico", name = "compose-m3", version.ref = "chart" } +firebase-bom = { group = "com.google.firebase", name = "firebase-bom", version.ref = "firebaseBom" } +firebase-crashlytics = { group = "com.google.firebase", name = "firebase-crashlytics-ktx" } junit4 = { group = "junit", name = "junit", version.ref = "junit4" } koin-android = { group = "io.insert-koin", name = "koin-android", version.ref = "koinAndroid" } koin-compose = { group = "io.insert-koin", name = "koin-androidx-compose", version.ref = "koinCompose" } @@ -71,7 +76,9 @@ room-compiler = { group = "androidx.room", name = "room-compiler", version.ref = room-ktx = { group = "androidx.room", name = "room-ktx", version.ref = "room" } room-runtime = { group = "androidx.room", name = "room-runtime", version.ref = "room" } +# Dependencies of the included build-logic android-gradlePlugin = { group = "com.android.tools.build", name = "gradle", version.ref = "androidGradlePlugin" } +firebase-crashlytics-gradlePlugin = { group = "com.google.firebase", name = "firebase-crashlytics-gradle", version.ref = "firebaseCrashlyticsPlugin" } kotlin-gradlePlugin = { group = "org.jetbrains.kotlin", name = "kotlin-gradle-plugin", version.ref = "kotlin" } ksp-gradlePlugin = { group = "com.google.devtools.ksp", name = "com.google.devtools.ksp.gradle.plugin", version.ref = "ksp" } junit = { group = "androidx.test.ext", name = "junit", version.ref = "junit" } @@ -81,16 +88,18 @@ espresso-core = { group = "androidx.test.espresso", name = "espresso-core", vers android-application = { id = "com.android.application", version.ref = "androidGradlePlugin" } android-library = { id = "com.android.library", version.ref = "androidGradlePlugin" } android-test = { id = "com.android.test", version.ref = "androidGradlePlugin" } +firebase-crashlytics = { id = "com.google.firebase.crashlytics", version.ref = "firebaseCrashlyticsPlugin" } +gms = { id = "com.google.gms.google-services", version.ref = "gmsPlugin" } kotlin-jvm = { id = "org.jetbrains.kotlin.jvm", version.ref = "kotlin" } kotlin-serialization = { id = "org.jetbrains.kotlin.plugin.serialization", version.ref = "kotlin" } ksp = { id = "com.google.devtools.ksp", version.ref = "ksp" } -org-jetbrains-kotlin-android = { id = "org.jetbrains.kotlin.android", version.ref = "org-jetbrains-kotlin-android" } protobuf = { id = "com.google.protobuf", version.ref = "protobufPlugin" } secrets = { id = "com.google.android.libraries.mapsplatform.secrets-gradle-plugin", version.ref = "secrets" } # Plugins defined by this project weightcontrol-android-application = { id = "weightcontrol.android.application", version = "unspecified" } weightcontrol-android-application-compose = { id = "weightcontrol.android.application.compose", version = "unspecified" } +weightcontrol-android-application-firebase = { id = "weightcontrol.android.application.firebase", version = "unspecified" } weightcontrol-android-feature = { id = "weightcontrol.android.feature", version = "unspecified" } weightcontrol-android-library = { id = "weightcontrol.android.library", version = "unspecified" } weightcontrol-android-library-compose = { id = "weightcontrol.android.library.compose", version = "unspecified" }