From 4d7ad96a094d4b7c6a4730003e0d460b05f0ac71 Mon Sep 17 00:00:00 2001 From: Phil Oliver <3497406+poliver@users.noreply.github.com> Date: Mon, 6 Oct 2025 22:14:25 -0400 Subject: [PATCH] Remove unused dependencies in `:app` (#3365) --- app/build.gradle.kts | 45 +++++++++++----- build-logic/convention/build.gradle.kts | 8 --- .../AndroidApplicationConventionPlugin.kt | 6 --- ...droidApplicationDatadogConventionPlugin.kt | 42 --------------- ...roidApplicationFirebaseConventionPlugin.kt | 51 ------------------- ...droidApplicationFlavorsConventionPlugin.kt | 23 --------- .../src/main/kotlin/HiltConventionPlugin.kt | 2 +- .../mesh/buildlogic/AndroidCompose.kt | 9 ---- build.gradle.kts | 14 +++++ core/analytics/build.gradle.kts | 2 + core/ui/build.gradle.kts | 3 ++ feature/intro/build.gradle.kts | 5 ++ feature/map/build.gradle.kts | 2 + feature/node/build.gradle.kts | 1 + feature/settings/build.gradle.kts | 3 ++ gradle/libs.versions.toml | 8 +-- .../ExampleInstrumentedTest.kt | 39 -------------- .../meshserviceexample/ExampleUnitTest.kt | 33 ------------ 18 files changed, 66 insertions(+), 230 deletions(-) delete mode 100644 build-logic/convention/src/main/kotlin/AndroidApplicationDatadogConventionPlugin.kt delete mode 100644 build-logic/convention/src/main/kotlin/AndroidApplicationFirebaseConventionPlugin.kt delete mode 100644 mesh_service_example/src/androidTest/kotlin/com/meshtastic/android/meshserviceexample/ExampleInstrumentedTest.kt delete mode 100644 mesh_service_example/src/test/kotlin/com/meshtastic/android/meshserviceexample/ExampleUnitTest.kt diff --git a/app/build.gradle.kts b/app/build.gradle.kts index cce84c5d2..83a86c9d2 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -27,7 +27,6 @@ plugins { alias(libs.plugins.meshtastic.android.application.compose) alias(libs.plugins.meshtastic.hilt) alias(libs.plugins.kotlin.parcelize) - alias(libs.plugins.meshtastic.kotlinx.serialization) alias(libs.plugins.devtools.ksp) alias(libs.plugins.secrets) alias(libs.plugins.dokka) @@ -202,29 +201,51 @@ dependencies { implementation(projects.feature.node) implementation(projects.feature.settings) - // Bundles - implementation(libs.bundles.markdown) - implementation(libs.bundles.coroutines) - implementation(libs.bundles.datastore) - implementation(libs.bundles.coil) - - // ZXing + implementation(libs.androidx.compose.material3.adaptive) + implementation(libs.androidx.compose.material3.navigationSuite) + implementation(libs.material) + implementation(libs.androidx.compose.material3) + implementation(libs.androidx.compose.material.iconsExtended) + implementation(libs.androidx.compose.ui.tooling.preview) + implementation(libs.compose.runtime.livedata) + implementation(libs.androidx.compose.ui.text) + implementation(libs.lifecycle.livedata.ktx) + implementation(libs.lifecycle.process) + implementation(libs.lifecycle.viewmodel.compose) + implementation(libs.lifecycle.runtime.compose) + implementation(libs.markdown.renderer) + implementation(libs.markdown.renderer.android) + implementation(libs.markdown.renderer.m3) + implementation(libs.kotlinx.coroutines.android) + implementation(libs.coil) + implementation(libs.coil.network.okhttp) + implementation(libs.coil.svg) + implementation(libs.hilt.lifecycle.viewmodel.compose) implementation(libs.zxing.android.embedded) { isTransitive = false } implementation(libs.zxing.core) - - // Individual dependencies (flavor-specific ones removed) implementation(libs.core.splashscreen) implementation(libs.emoji2.emojipicker) - implementation(libs.kotlinx.collections.immutable) implementation(libs.kotlinx.serialization.json) implementation(libs.org.eclipse.paho.client.mqttv3) implementation(libs.streamsupport.minifuture) implementation(libs.usb.serial.android) implementation(libs.work.runtime.ktx) - implementation(libs.core.location.altitude) implementation(libs.accompanist.permissions) implementation(libs.timber) + debugImplementation(libs.androidx.compose.ui.testManifest) + + googleImplementation(libs.location.services) + + fdroidImplementation(libs.osmdroid.android) + fdroidImplementation(libs.osmdroid.geopackage) { exclude(group = "com.j256.ormlite") } + + androidTestImplementation(libs.androidx.compose.ui.test) + androidTestImplementation(libs.androidx.test.runner) + + testImplementation(libs.ext.junit) + testImplementation(libs.junit) + dokkaPlugin(libs.dokka.android.documentation.plugin) } diff --git a/build-logic/convention/build.gradle.kts b/build-logic/convention/build.gradle.kts index 84cac7464..c19069a51 100644 --- a/build-logic/convention/build.gradle.kts +++ b/build-logic/convention/build.gradle.kts @@ -82,14 +82,6 @@ gradlePlugin { id = libs.plugins.meshtastic.android.lint.get().pluginId implementationClass = "AndroidLintConventionPlugin" } - register("androidFirebase") { - id = libs.plugins.meshtastic.android.application.firebase.get().pluginId - implementationClass = "AndroidApplicationFirebaseConventionPlugin" - } - register("androidDatadog") { - id = libs.plugins.meshtastic.android.application.datadog.get().pluginId - implementationClass = "AndroidApplicationDatadogConventionPlugin" - } register("androidLibraryCompose") { id = libs.plugins.meshtastic.android.library.compose.get().pluginId implementationClass = "AndroidLibraryComposeConventionPlugin" diff --git a/build-logic/convention/src/main/kotlin/AndroidApplicationConventionPlugin.kt b/build-logic/convention/src/main/kotlin/AndroidApplicationConventionPlugin.kt index 3b7856523..c8e6901f7 100644 --- a/build-logic/convention/src/main/kotlin/AndroidApplicationConventionPlugin.kt +++ b/build-logic/convention/src/main/kotlin/AndroidApplicationConventionPlugin.kt @@ -64,12 +64,6 @@ class AndroidApplicationConventionPlugin : Plugin { buildFeatures { buildConfig = true } - - dependencies { - "testImplementation"(libs.findBundle("testing").get()) - "androidTestImplementation"(libs.findBundle("testing.android").get()) - } - } } } diff --git a/build-logic/convention/src/main/kotlin/AndroidApplicationDatadogConventionPlugin.kt b/build-logic/convention/src/main/kotlin/AndroidApplicationDatadogConventionPlugin.kt deleted file mode 100644 index d061d659a..000000000 --- a/build-logic/convention/src/main/kotlin/AndroidApplicationDatadogConventionPlugin.kt +++ /dev/null @@ -1,42 +0,0 @@ -/* - * 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 . - */ - -import com.android.build.api.dsl.ApplicationExtension -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 - - -/** - * Convention plugin to apply and configure Datadog for Android applications. - * This plugin should only be applied to variants that require Datadog integration (e.g., 'google' flavor). - */ -class AndroidApplicationDatadogConventionPlugin : Plugin { - override fun apply(target: Project) { - with(target) { - extensions.configure { - apply(plugin = libs.findPlugin("datadog").get().get().pluginId) - dependencies { - "googleImplementation"(libs.findBundle("datadog").get()) - } - } - } - } -} diff --git a/build-logic/convention/src/main/kotlin/AndroidApplicationFirebaseConventionPlugin.kt b/build-logic/convention/src/main/kotlin/AndroidApplicationFirebaseConventionPlugin.kt deleted file mode 100644 index 764353481..000000000 --- a/build-logic/convention/src/main/kotlin/AndroidApplicationFirebaseConventionPlugin.kt +++ /dev/null @@ -1,51 +0,0 @@ -/* - * 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 . - */ - -import com.android.build.api.dsl.ApplicationExtension -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 -import org.gradle.kotlin.dsl.exclude - -class AndroidApplicationFirebaseConventionPlugin : Plugin { - override fun apply(target: Project) { - with(target) { - apply(plugin = libs.findPlugin("firebase-crashlytics").get().get().pluginId) - apply(plugin = libs.findPlugin("google-services").get().get().pluginId) - extensions.configure { - dependencies { - val bom = libs.findLibrary("firebase-bom").get() - "googleImplementation"(platform(bom)) - "googleImplementation"(libs.findBundle("firebase").get()) { - // Exclusion of protobuf / protolite dependencies is necessary as we depend - // on different versions than those included. - exclude(group = "com.google.protobuf", module = "protobuf-java") - exclude(group = "com.google.protobuf", module = "protobuf-kotlin") - exclude(group = "com.google.protobuf", module = "protobuf-javalite") - exclude( - group = "com.google.firebase", - module = "protolite-well-known-types" - ) - } - } - } - } - } -} diff --git a/build-logic/convention/src/main/kotlin/AndroidApplicationFlavorsConventionPlugin.kt b/build-logic/convention/src/main/kotlin/AndroidApplicationFlavorsConventionPlugin.kt index 4dbfa0f1d..879df99a2 100644 --- a/build-logic/convention/src/main/kotlin/AndroidApplicationFlavorsConventionPlugin.kt +++ b/build-logic/convention/src/main/kotlin/AndroidApplicationFlavorsConventionPlugin.kt @@ -31,29 +31,6 @@ class AndroidApplicationFlavorsConventionPlugin : Plugin { with(target) { extensions.configure { configureFlavors(this) - productFlavors { - all { - if (name == MeshtasticFlavor.google.name) { - apply(plugin = "meshtastic.android.application.firebase") - apply(plugin = "meshtastic.android.application.datadog") - dependencies { - // Google specific dependencies - "googleImplementation"(libs.findBundle("maps-compose").get()) - "googleImplementation"(libs.findLibrary("awesome-app-rating").get()) - } - } else if (name == MeshtasticFlavor.fdroid.name) { - dependencies { - // F-Droid specific dependencies - "fdroidImplementation"(libs.findBundle("osm").get()) - "fdroidImplementation"( - libs.findLibrary("osmdroid-geopackage").get() - ) { - exclude(group = "com.j256.ormlite") - } - } - } - } - } } } } diff --git a/build-logic/convention/src/main/kotlin/HiltConventionPlugin.kt b/build-logic/convention/src/main/kotlin/HiltConventionPlugin.kt index b6757aa4c..ff0afd9a2 100644 --- a/build-logic/convention/src/main/kotlin/HiltConventionPlugin.kt +++ b/build-logic/convention/src/main/kotlin/HiltConventionPlugin.kt @@ -28,7 +28,7 @@ class HiltConventionPlugin : Plugin { dependencies { "ksp"(libs.findLibrary("hilt.compiler").get()) - "implementation"(libs.findBundle("hilt").get()) + "implementation"(libs.findLibrary("hilt-android").get()) "androidTestImplementation"(libs.findBundle("testing.hilt").get()) } diff --git a/build-logic/convention/src/main/kotlin/com/geeksville/mesh/buildlogic/AndroidCompose.kt b/build-logic/convention/src/main/kotlin/com/geeksville/mesh/buildlogic/AndroidCompose.kt index be41f10b6..120e7b3e2 100644 --- a/build-logic/convention/src/main/kotlin/com/geeksville/mesh/buildlogic/AndroidCompose.kt +++ b/build-logic/convention/src/main/kotlin/com/geeksville/mesh/buildlogic/AndroidCompose.kt @@ -35,25 +35,16 @@ internal fun Project.configureAndroidCompose( compose = true } - //needed for navigation3 - pluginManager.apply(libs.findPlugin("meshtastic-kotlinx-serialization").get().get().pluginId) - dependencies { val bom = libs.findLibrary("androidx-compose-bom").get() "implementation"(platform(bom)) "androidTestImplementation"(platform(bom)) - "implementation"(libs.findBundle("ui").get()) - "implementation"(libs.findBundle("adaptive").get()) - "implementation"(libs.findBundle("lifecycle").get()) "implementation"(libs.findBundle("navigation").get()) - "androidTestImplementation"(libs.findBundle("testing.navigation").get()) - "implementation"(libs.findBundle("navigation3").get()) "implementation"(libs.findBundle("ui-tooling").get()) "implementation"(libs.findLibrary("androidx-compose-ui-tooling-preview").get()) "implementation"(libs.findLibrary("androidx-compose-runtime").get()) "implementation"(libs.findLibrary("androidx-compose-runtime-tracing").get()) "debugImplementation"(libs.findLibrary("androidx-compose-ui-tooling").get()) - "debugImplementation"(libs.findLibrary("androidx-compose-ui-testManifest").get()) } } diff --git a/build.gradle.kts b/build.gradle.kts index f8b47185e..00ddba098 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -90,4 +90,18 @@ dependencies { kover(projects.feature.map) kover(projects.feature.node) kover(projects.feature.settings) +} + +dependencyAnalysis { + structure { + ignoreKtx(true) + } + + issues { + all { + onUnusedDependencies { + exclude("androidx.compose.ui:ui-test-manifest") + } + } + } } \ No newline at end of file diff --git a/core/analytics/build.gradle.kts b/core/analytics/build.gradle.kts index c20df85b9..9cb2ad9a9 100644 --- a/core/analytics/build.gradle.kts +++ b/core/analytics/build.gradle.kts @@ -26,6 +26,8 @@ dependencies { implementation(project(":core:model")) implementation(libs.timber) implementation(libs.appcompat) + implementation(libs.hilt.lifecycle.viewmodel.compose) + implementation(libs.navigation.compose) implementation(libs.lifecycle.process) googleImplementation(platform(libs.firebase.bom)) googleImplementation(libs.bundles.firebase) { diff --git a/core/ui/build.gradle.kts b/core/ui/build.gradle.kts index 1065e599f..c17bb0fe1 100644 --- a/core/ui/build.gradle.kts +++ b/core/ui/build.gradle.kts @@ -33,5 +33,8 @@ dependencies { implementation(libs.bundles.coroutines) implementation(libs.bundles.markdown) + implementation(libs.bundles.ui) + implementation(libs.emoji2.emojipicker) + implementation(libs.hilt.lifecycle.viewmodel.compose) } diff --git a/feature/intro/build.gradle.kts b/feature/intro/build.gradle.kts index 7a07b1679..dc5a1e045 100644 --- a/feature/intro/build.gradle.kts +++ b/feature/intro/build.gradle.kts @@ -19,11 +19,16 @@ plugins { alias(libs.plugins.kover) alias(libs.plugins.meshtastic.android.library) alias(libs.plugins.meshtastic.android.library.compose) + alias(libs.plugins.meshtastic.kotlinx.serialization) } android { namespace = "org.meshtastic.feature.intro" } dependencies { implementation(projects.core.strings) + + implementation(libs.bundles.ui) implementation(libs.accompanist.permissions) + implementation(libs.navigation3.runtime) + implementation(libs.navigation3.ui) } diff --git a/feature/map/build.gradle.kts b/feature/map/build.gradle.kts index 5d8ccf228..79714097f 100644 --- a/feature/map/build.gradle.kts +++ b/feature/map/build.gradle.kts @@ -40,9 +40,11 @@ dependencies { implementation(libs.bundles.coroutines) implementation(libs.bundles.lifecycle) implementation(libs.bundles.osm) + implementation(libs.bundles.ui) googleImplementation(libs.bundles.maps.compose) implementation(libs.accompanist.permissions) implementation(libs.annotation) + implementation(libs.hilt.lifecycle.viewmodel.compose) implementation(libs.timber) } diff --git a/feature/node/build.gradle.kts b/feature/node/build.gradle.kts index 0566d62fa..34ba6fd49 100644 --- a/feature/node/build.gradle.kts +++ b/feature/node/build.gradle.kts @@ -34,5 +34,6 @@ dependencies { implementation(projects.core.strings) implementation(projects.core.ui) + implementation(libs.bundles.ui) implementation(libs.timber) } diff --git a/feature/settings/build.gradle.kts b/feature/settings/build.gradle.kts index 58c9fe287..e88167860 100644 --- a/feature/settings/build.gradle.kts +++ b/feature/settings/build.gradle.kts @@ -37,7 +37,10 @@ dependencies { implementation(projects.core.strings) implementation(projects.core.ui) + implementation(libs.bundles.ui) + implementation(libs.accompanist.permissions) + implementation(libs.hilt.lifecycle.viewmodel.compose) implementation(libs.kotlinx.collections.immutable) implementation(libs.timber) implementation(libs.zxing.android.embedded) diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 23ea83856..0b27b0ed1 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -51,7 +51,7 @@ core-splashscreen = { module = "androidx.core:core-splashscreen", version = "1.0 datastore = { module = "androidx.datastore:datastore", version.ref = "datastore" } datastore-preferences = { module = "androidx.datastore:datastore-preferences", version.ref = "datastore" } emoji2-emojipicker = { module = "androidx.emoji2:emoji2-emojipicker", version = "1.6.0" } -hilt-navigation-compose = { module = "androidx.hilt:hilt-navigation-compose", version = "1.3.0" } +hilt-lifecycle-viewmodel-compose = { module = "androidx.hilt:hilt-lifecycle-viewmodel-compose", version = "1.3.0" } lifecycle-common-java8 = { module = "androidx.lifecycle:lifecycle-common-java8", version.ref = "lifecycle" } lifecycle-livedata-ktx = { module = "androidx.lifecycle:lifecycle-livedata-ktx", version.ref = "lifecycle" } lifecycle-process = { module = "androidx.lifecycle:lifecycle-process", version.ref = "lifecycle" } @@ -126,6 +126,7 @@ ktorfit = { module = "de.jensklingenberg.ktorfit:ktorfit-lib", version.ref = "kt okhttp3-logging-interceptor = { module = "com.squareup.okhttp3:logging-interceptor", version = "5.1.0" } # Testing +androidx-test-runner = { module = "androidx.test:runner", version = "1.7.0" } espresso-core = { module = "androidx.test.espresso:espresso-core", version = "3.7.0" } ext-junit = { module = "androidx.test.ext:junit", version = "1.3.0" } junit = { module = "junit:junit", version = "4.13.2" } @@ -191,9 +192,6 @@ room = ["room-runtime", "room-ktx"] # Coroutines coroutines = ["kotlinx-coroutines-android", "kotlinx-coroutines-guava"] -# Dependency Injection -hilt = ["hilt-android", "hilt-navigation-compose"] - # Google firebase = ["firebase-analytics", "firebase-crashlytics"] maps-compose = ["location-services", "maps-compose", "maps-compose-utils", "maps-compose-widgets"] @@ -257,8 +255,6 @@ spotless = { id = "com.diffplug.spotless", version = "8.0.0" } # Meshtastic meshtastic-android-application = { id = "meshtastic.android.application" } meshtastic-android-application-compose = { id = "meshtastic.android.application.compose" } -meshtastic-android-application-datadog = { id = "meshtastic.android.application.datadog" } -meshtastic-android-application-firebase = { id = "meshtastic.android.application.firebase" } meshtastic-android-application-flavors = { id = "meshtastic.android.application.flavors" } meshtastic-android-library = { id = "meshtastic.android.library" } meshtastic-android-library-compose = { id = "meshtastic.android.library.compose" } diff --git a/mesh_service_example/src/androidTest/kotlin/com/meshtastic/android/meshserviceexample/ExampleInstrumentedTest.kt b/mesh_service_example/src/androidTest/kotlin/com/meshtastic/android/meshserviceexample/ExampleInstrumentedTest.kt deleted file mode 100644 index 3208e2828..000000000 --- a/mesh_service_example/src/androidTest/kotlin/com/meshtastic/android/meshserviceexample/ExampleInstrumentedTest.kt +++ /dev/null @@ -1,39 +0,0 @@ -/* - * 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 . - */ - -package com.meshtastic.android.meshserviceexample - -import androidx.test.ext.junit.runners.AndroidJUnit4 -import androidx.test.platform.app.InstrumentationRegistry -import org.junit.Assert -import org.junit.Test -import org.junit.runner.RunWith - -/** - * Instrumented test, which will execute on an Android device. - * - * @see Testing documentation - */ -@RunWith(AndroidJUnit4::class) -class ExampleInstrumentedTest { - @Test - fun useAppContext() { - // Context of the app under test. - val appContext = InstrumentationRegistry.getInstrumentation().targetContext - Assert.assertEquals("com.meshtastic.android.meshserviceexample", appContext.packageName) - } -} diff --git a/mesh_service_example/src/test/kotlin/com/meshtastic/android/meshserviceexample/ExampleUnitTest.kt b/mesh_service_example/src/test/kotlin/com/meshtastic/android/meshserviceexample/ExampleUnitTest.kt deleted file mode 100644 index a59af69f9..000000000 --- a/mesh_service_example/src/test/kotlin/com/meshtastic/android/meshserviceexample/ExampleUnitTest.kt +++ /dev/null @@ -1,33 +0,0 @@ -/* - * 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 . - */ - -package com.meshtastic.android.meshserviceexample - -import org.junit.Assert -import org.junit.Test - -/** - * Example local unit test, which will execute on the development machine (host). - * - * @see Testing documentation - */ -class ExampleUnitTest { - @Test - fun addition_isCorrect() { - Assert.assertEquals(4, (2 + 2).toLong()) - } -}