mirror of
https://github.com/meshtastic/Meshtastic-Android.git
synced 2025-12-24 00:07:48 -05:00
refactor(build): Create a dedicated analytics convention plugin (#3961)
Signed-off-by: James Rich <2199651+jamesarich@users.noreply.github.com>
This commit is contained in:
@@ -140,13 +140,6 @@ android {
|
||||
// Configure existing product flavors (defined by convention plugin)
|
||||
// with their dynamic version names.
|
||||
productFlavors {
|
||||
all {
|
||||
if (name == "google") {
|
||||
apply(plugin = libs.plugins.google.services.get().pluginId)
|
||||
apply(plugin = libs.plugins.firebase.crashlytics.get().pluginId)
|
||||
}
|
||||
}
|
||||
|
||||
named("google") { versionName = "${defaultConfig.versionName} (${defaultConfig.versionCode}) google" }
|
||||
named("fdroid") { versionName = "${defaultConfig.versionName} (${defaultConfig.versionCode}) fdroid" }
|
||||
}
|
||||
|
||||
@@ -131,6 +131,10 @@ gradlePlugin {
|
||||
id = libs.plugins.meshtastic.kotlinx.serialization.get().pluginId
|
||||
implementationClass = "KotlinXSerializationConventionPlugin"
|
||||
}
|
||||
register("meshtasticAnalytics") {
|
||||
id = libs.plugins.meshtastic.analytics.get().pluginId
|
||||
implementationClass = "AnalyticsConventionPlugin"
|
||||
}
|
||||
register("meshtasticHilt") {
|
||||
id = libs.plugins.meshtastic.hilt.get().pluginId
|
||||
implementationClass = "HiltConventionPlugin"
|
||||
|
||||
@@ -0,0 +1,61 @@
|
||||
/*
|
||||
* Copyright (c) 2025 Meshtastic LLC
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import com.android.build.api.dsl.ApplicationExtension
|
||||
import com.android.build.api.variant.ApplicationAndroidComponentsExtension
|
||||
import com.datadog.gradle.plugin.DdExtension
|
||||
import com.datadog.gradle.plugin.InstrumentationMode
|
||||
import com.datadog.gradle.plugin.SdkCheckLevel
|
||||
import org.gradle.api.Plugin
|
||||
import org.gradle.api.Project
|
||||
import org.gradle.kotlin.dsl.apply
|
||||
import org.gradle.kotlin.dsl.configure
|
||||
|
||||
class AnalyticsConventionPlugin : Plugin<Project> {
|
||||
override fun apply(target: Project) {
|
||||
with(target) {
|
||||
extensions.configure<ApplicationExtension> {
|
||||
defaultConfig {
|
||||
productFlavors {
|
||||
all {
|
||||
if (name == "google") {
|
||||
apply(plugin = "com.google.gms.google-services")
|
||||
apply(plugin = "com.google.firebase.crashlytics")
|
||||
apply(plugin = "com.datadoghq.dd-sdk-android-gradle-plugin")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
extensions.configure<ApplicationAndroidComponentsExtension> {
|
||||
onVariants { variant ->
|
||||
if (variant.flavorName == "google") {
|
||||
extensions.configure<DdExtension> {
|
||||
variants {
|
||||
register(variant.name) {
|
||||
site = "US5"
|
||||
composeInstrumentation = InstrumentationMode.AUTO
|
||||
}
|
||||
}
|
||||
checkProjectDependencies = SdkCheckLevel.NONE
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -17,12 +17,10 @@
|
||||
|
||||
import com.android.build.api.dsl.ApplicationExtension
|
||||
import com.geeksville.mesh.buildlogic.configureKotlinAndroid
|
||||
import com.geeksville.mesh.buildlogic.libs
|
||||
import org.gradle.api.Plugin
|
||||
import org.gradle.api.Project
|
||||
import org.gradle.kotlin.dsl.apply
|
||||
import org.gradle.kotlin.dsl.configure
|
||||
import org.gradle.kotlin.dsl.dependencies
|
||||
|
||||
class AndroidApplicationConventionPlugin : Plugin<Project> {
|
||||
override fun apply(target: Project) {
|
||||
@@ -33,6 +31,7 @@ class AndroidApplicationConventionPlugin : Plugin<Project> {
|
||||
apply(plugin = "meshtastic.android.lint")
|
||||
apply(plugin = "meshtastic.detekt")
|
||||
apply(plugin = "meshtastic.spotless")
|
||||
apply(plugin = "meshtastic.analytics")
|
||||
apply(plugin = "com.autonomousapps.dependency-analysis")
|
||||
|
||||
extensions.configure<ApplicationExtension> {
|
||||
|
||||
@@ -30,17 +30,17 @@ dependencies {
|
||||
implementation(libs.androidx.navigation.runtime)
|
||||
implementation(libs.timber)
|
||||
|
||||
googleImplementation(libs.dd.sdk.android.compose)
|
||||
googleImplementation(libs.dd.sdk.android.logs)
|
||||
googleImplementation(libs.dd.sdk.android.rum)
|
||||
googleImplementation(libs.dd.sdk.android.session.replay)
|
||||
googleImplementation(libs.dd.sdk.android.session.replay.compose)
|
||||
googleImplementation(libs.dd.sdk.android.timber)
|
||||
googleImplementation(libs.dd.sdk.android.trace)
|
||||
googleImplementation(libs.dd.sdk.android.trace.otel)
|
||||
googleImplementation(platform(libs.firebase.bom))
|
||||
googleImplementation(libs.firebase.analytics)
|
||||
googleImplementation(libs.firebase.crashlytics)
|
||||
googleApi(libs.dd.sdk.android.compose)
|
||||
googleApi(libs.dd.sdk.android.logs)
|
||||
googleApi(libs.dd.sdk.android.rum)
|
||||
googleApi(libs.dd.sdk.android.session.replay)
|
||||
googleApi(libs.dd.sdk.android.session.replay.compose)
|
||||
googleApi(libs.dd.sdk.android.timber)
|
||||
googleApi(libs.dd.sdk.android.trace)
|
||||
googleApi(libs.dd.sdk.android.trace.otel)
|
||||
googleApi(platform(libs.firebase.bom))
|
||||
googleApi(libs.firebase.analytics)
|
||||
googleApi(libs.firebase.crashlytics)
|
||||
}
|
||||
|
||||
val googleServiceKeywords = listOf("crashlytics", "google", "datadog")
|
||||
|
||||
@@ -213,6 +213,7 @@ room = { id = "androidx.room", version.ref = "room" }
|
||||
spotless = { id = "com.diffplug.spotless", version = "8.1.0" }
|
||||
|
||||
# Meshtastic
|
||||
meshtastic-analytics = { id = "meshtastic.analytics" }
|
||||
meshtastic-android-application = { id = "meshtastic.android.application" }
|
||||
meshtastic-android-application-compose = { id = "meshtastic.android.application.compose" }
|
||||
meshtastic-android-application-flavors = { id = "meshtastic.android.application.flavors" }
|
||||
|
||||
Reference in New Issue
Block a user