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:
James Rich 2025-12-10 22:47:25 -06:00 committed by GitHub
parent ce732203ae
commit fdff7315fe
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 78 additions and 20 deletions

View file

@ -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"

View file

@ -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
}
}
}
}
}
}
}

View file

@ -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> {