Skip to content

Commit e3dd432

Browse files
authored
fix(build): apply Datadog and Firebase plugins _only_ to google flavor (#3240)
Signed-off-by: James Rich <[email protected]>
1 parent 48a27ba commit e3dd432

File tree

6 files changed

+89
-19
lines changed

6 files changed

+89
-19
lines changed

app/build.gradle.kts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,10 @@ plugins {
2525
alias(libs.plugins.meshtastic.android.application)
2626
alias(libs.plugins.meshtastic.android.application.flavors)
2727
alias(libs.plugins.meshtastic.android.application.compose)
28-
alias(libs.plugins.meshtastic.android.application.firebase)
2928
alias(libs.plugins.meshtastic.hilt)
3029
alias(libs.plugins.kotlin.parcelize)
3130
alias(libs.plugins.meshtastic.kotlinx.serialization)
3231
alias(libs.plugins.devtools.ksp)
33-
alias(libs.plugins.datadog)
3432
alias(libs.plugins.secrets)
3533
alias(libs.plugins.dokka)
3634
alias(libs.plugins.kover)
@@ -131,6 +129,13 @@ android {
131129
),
132130
)
133131
ndk { abiFilters += listOf("armeabi-v7a", "arm64-v8a", "x86", "x86_64") }
132+
133+
dependenciesInfo {
134+
// Disables dependency metadata when building APKs (for IzzyOnDroid/F-Droid)
135+
includeInApk = false
136+
// Disables dependency metadata when building Android App Bundles (for Google Play)
137+
includeInBundle = false
138+
}
134139
}
135140

136141
// Configure existing product flavors (defined by convention plugin)

build-logic/convention/build.gradle.kts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ dependencies {
4444
compileOnly(libs.compose.gradlePlugin)
4545
compileOnly(libs.detekt.gradle)
4646
compileOnly(libs.firebase.crashlytics.gradlePlugin)
47+
compileOnly(libs.firebase.performance.gradlePlugin)
4748
compileOnly(libs.kotlin.gradlePlugin)
4849
compileOnly(libs.ksp.gradlePlugin)
4950
compileOnly(libs.room.gradlePlugin)
@@ -81,6 +82,10 @@ gradlePlugin {
8182
id = libs.plugins.meshtastic.android.application.firebase.get().pluginId
8283
implementationClass = "AndroidApplicationFirebaseConventionPlugin"
8384
}
85+
register("androidDatadog") {
86+
id = libs.plugins.meshtastic.android.application.datadog.get().pluginId
87+
implementationClass = "AndroidApplicationDatadogConventionPlugin"
88+
}
8489
register("androidLibraryCompose") {
8590
id = libs.plugins.meshtastic.android.library.compose.get().pluginId
8691
implementationClass = "AndroidLibraryComposeConventionPlugin"
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
/*
2+
* Copyright (c) 2025 Meshtastic LLC
3+
*
4+
* This program is free software: you can redistribute it and/or modify
5+
* it under the terms of the GNU General Public License as published by
6+
* the Free Software Foundation, either version 3 of the License, or
7+
* (at your option) any later version.
8+
*
9+
* This program is distributed in the hope that it will be useful,
10+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
* GNU General Public License for more details.
13+
*
14+
* You should have received a copy of the GNU General Public License
15+
* along with this program. If not, see <https://www.gnu.org/licenses/>.
16+
*/
17+
18+
import com.android.build.api.dsl.ApplicationExtension
19+
import com.geeksville.mesh.buildlogic.libs
20+
import org.gradle.api.Plugin
21+
import org.gradle.api.Project
22+
import org.gradle.kotlin.dsl.apply
23+
import org.gradle.kotlin.dsl.configure
24+
import org.gradle.kotlin.dsl.dependencies
25+
26+
27+
/**
28+
* Convention plugin to apply and configure Datadog for Android applications.
29+
* This plugin should only be applied to variants that require Datadog integration (e.g., 'google' flavor).
30+
*/
31+
class AndroidApplicationDatadogConventionPlugin : Plugin<Project> {
32+
override fun apply(target: Project) {
33+
with(target) {
34+
extensions.configure<ApplicationExtension> {
35+
apply(plugin = libs.findPlugin("datadog").get().get().pluginId)
36+
dependencies {
37+
"googleImplementation"(libs.findBundle("datadog").get())
38+
}
39+
}
40+
}
41+
}
42+
}

build-logic/convention/src/main/kotlin/AndroidApplicationFirebaseConventionPlugin.kt

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
*/
1717

1818
import com.android.build.api.dsl.ApplicationExtension
19-
import com.geeksville.mesh.buildlogic.MeshtasticFlavor
2019
import com.geeksville.mesh.buildlogic.libs
2120
import com.google.firebase.crashlytics.buildtools.gradle.CrashlyticsExtension
2221
import org.gradle.api.Plugin
@@ -29,13 +28,14 @@ import org.gradle.kotlin.dsl.exclude
2928
class AndroidApplicationFirebaseConventionPlugin : Plugin<Project> {
3029
override fun apply(target: Project) {
3130
with(target) {
32-
apply(plugin = "com.google.gms.google-services")
33-
apply(plugin = "com.google.firebase.crashlytics")
34-
31+
apply(plugin = libs.findPlugin("firebase-crashlytics").get().get().pluginId)
32+
apply(plugin = libs.findPlugin("firebase-perf").get().get().pluginId)
33+
apply(plugin = libs.findPlugin("google-services").get().get().pluginId)
34+
extensions.configure<ApplicationExtension> {
3535
dependencies {
3636
val bom = libs.findLibrary("firebase-bom").get()
37-
"implementation"(platform(bom))
38-
"implementation"(libs.findBundle("firebase").get()) {
37+
"googleImplementation"(platform(bom))
38+
"googleImplementation"(libs.findBundle("firebase").get()) {
3939
/*
4040
Exclusion of protobuf / protolite dependencies is necessary as the
4141
datastore-proto brings in protobuf dependencies. These are the source of truth
@@ -45,9 +45,13 @@ class AndroidApplicationFirebaseConventionPlugin : Plugin<Project> {
4545
exclude(group = "com.google.protobuf", module = "protobuf-java")
4646
exclude(group = "com.google.protobuf", module = "protobuf-kotlin")
4747
exclude(group = "com.google.protobuf", module = "protobuf-javalite")
48-
exclude(group = "com.google.firebase", module = "protolite-well-known-types")
48+
exclude(
49+
group = "com.google.firebase",
50+
module = "protolite-well-known-types"
51+
)
4952
}
5053
}
54+
}
5155

5256
extensions.configure<ApplicationExtension> {
5357
buildTypes.configureEach {

build-logic/convention/src/main/kotlin/AndroidApplicationFlavorsConventionPlugin.kt

Lines changed: 23 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,12 @@
1616
*/
1717

1818
import com.android.build.api.dsl.ApplicationExtension
19+
import com.geeksville.mesh.buildlogic.MeshtasticFlavor
1920
import com.geeksville.mesh.buildlogic.configureFlavors
2021
import com.geeksville.mesh.buildlogic.libs
2122
import org.gradle.api.Plugin
2223
import org.gradle.api.Project
24+
import org.gradle.kotlin.dsl.apply
2325
import org.gradle.kotlin.dsl.configure
2426
import org.gradle.kotlin.dsl.dependencies
2527
import org.gradle.kotlin.dsl.exclude
@@ -29,17 +31,28 @@ class AndroidApplicationFlavorsConventionPlugin : Plugin<Project> {
2931
with(target) {
3032
extensions.configure<ApplicationExtension> {
3133
configureFlavors(this)
32-
dependencies {
33-
// F-Droid specific dependencies
34-
"fdroidImplementation"(libs.findBundle("osm").get())
35-
"fdroidImplementation"(libs.findLibrary("osmdroid-geopackage").get()) {
36-
exclude(group = "com.j256.ormlite")
34+
productFlavors {
35+
all {
36+
if (name == MeshtasticFlavor.google.name) {
37+
apply(plugin = "meshtastic.android.application.firebase")
38+
apply(plugin = "meshtastic.android.application.datadog")
39+
dependencies {
40+
// Google specific dependencies
41+
"googleImplementation"(libs.findBundle("maps-compose").get())
42+
"googleImplementation"(libs.findLibrary("awesome-app-rating").get())
43+
}
44+
} else if (name == MeshtasticFlavor.fdroid.name) {
45+
dependencies {
46+
// F-Droid specific dependencies
47+
"fdroidImplementation"(libs.findBundle("osm").get())
48+
"fdroidImplementation"(
49+
libs.findLibrary("osmdroid-geopackage").get()
50+
) {
51+
exclude(group = "com.j256.ormlite")
52+
}
53+
}
54+
}
3755
}
38-
39-
// Google specific dependencies
40-
"googleImplementation"(libs.findBundle("maps-compose").get())
41-
"googleImplementation"(libs.findLibrary("awesome-app-rating").get())
42-
"googleImplementation"(libs.findBundle("datadog").get())
4356
}
4457
}
4558
}

gradle/libs.versions.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -251,6 +251,7 @@ spotless = { id = "com.diffplug.spotless", version = "8.0.0" }
251251
# Meshtastic
252252
meshtastic-android-application = { id = "meshtastic.android.application" }
253253
meshtastic-android-application-compose = { id = "meshtastic.android.application.compose" }
254+
meshtastic-android-application-datadog = { id = "meshtastic.android.application.datadog" }
254255
meshtastic-android-application-firebase = { id = "meshtastic.android.application.firebase" }
255256
meshtastic-android-application-flavors = { id = "meshtastic.android.application.flavors" }
256257
meshtastic-android-library = { id = "meshtastic.android.library" }

0 commit comments

Comments
 (0)