refactor: slim down per-module dependencies

dependency-analysis plugin coming in clutch as usual
This commit is contained in:
Harsh Shandilya 2025-08-04 23:02:51 +05:30
parent 541acf4ef1
commit eed64b95df
7 changed files with 2 additions and 99 deletions

View file

@ -6,9 +6,6 @@
*/
@file:Suppress("UnstableApiUsage")
import com.android.build.api.dsl.ApplicationExtension
import dev.msfjarvis.claw.gradle.addTestDependencies
plugins {
id("dev.msfjarvis.claw.android-application")
id("dev.msfjarvis.claw.rename-artifacts")
@ -18,19 +15,16 @@ plugins {
id("dev.msfjarvis.claw.versioning-plugin")
id("kotlin-parcelize")
alias(libs.plugins.aboutlibraries)
alias(libs.plugins.android.junit5)
alias(libs.plugins.anvil)
alias(libs.plugins.modulegraphassert)
alias(libs.plugins.whetstone)
alias(libs.plugins.licensee)
alias(libs.plugins.tracelog)
alias(libs.plugins.kotlin.composeCompiler)
alias(libs.plugins.kotlin.serialization)
alias(libs.plugins.dependencyAnalysis)
}
// Directly using the generated `android` accessor lights up bright red
extensions.configure<ApplicationExtension> {
android {
namespace = "dev.msfjarvis.claw.android"
defaultConfig.applicationId = "dev.msfjarvis.claw.android"
defaultConfig.testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
@ -93,7 +87,6 @@ dependencies {
implementation(libs.androidx.compose.runtime)
implementation(libs.androidx.compose.ui)
implementation(libs.androidx.compose.ui.text)
implementation(libs.androidx.compose.ui.util)
implementation(libs.androidx.core.splashscreen)
implementation(libs.androidx.lifecycle.compose)
implementation(libs.androidx.material3.navigation3)
@ -105,7 +98,6 @@ dependencies {
implementation(libs.dagger)
implementation(libs.eithernet)
implementation(libs.haze)
implementation(libs.haze.materials)
implementation(libs.javax.inject)
implementation(libs.kotlinx.collections.immutable)
implementation(libs.kotlinx.coroutines.core)
@ -127,8 +119,4 @@ dependencies {
implementation(projects.web)
kapt(libs.dagger.compiler)
addTestDependencies(project)
androidTestImplementation(libs.androidx.test.uiautomator)
androidTestImplementation(libs.leakcanary.android.test)
}

View file

@ -1,59 +0,0 @@
/*
* Copyright © Harsh Shandilya.
* Use of this source code is governed by an MIT-style
* license that can be found in the LICENSE file or at
* https://opensource.org/licenses/MIT.
*/
package dev.msfjarvis.claw.android
import androidx.test.platform.app.InstrumentationRegistry
import androidx.test.uiautomator.By
import androidx.test.uiautomator.BySelector
import androidx.test.uiautomator.UiDevice
import androidx.test.uiautomator.UiObject2
import androidx.test.uiautomator.Until
import com.google.common.truth.Truth.assertThat
import de.mannodermaus.junit5.ActivityScenarioExtension
import leakcanary.repeatingAndroidInProcessScenario
import org.junit.jupiter.api.BeforeEach
import org.junit.jupiter.api.Test
import org.junit.jupiter.api.extension.RegisterExtension
import shark.HeapDiff
class HeapGrowthCheck {
@JvmField
@RegisterExtension
@Suppress("Unused")
val scenarioExtension = ActivityScenarioExtension.launch<MainActivity>()
private val detector = HeapDiff.repeatingAndroidInProcessScenario()
private lateinit var device: UiDevice
@BeforeEach
fun setUp() {
val instrumentation = InstrumentationRegistry.getInstrumentation()
device = UiDevice.getInstance(instrumentation)
}
@Test
fun verify_heap_growth() {
val heapGrowth = detector.findRepeatedlyGrowingObjects { device.exploreScreens() }
assertThat(heapGrowth.growingObjects).isEmpty()
}
private companion object {
fun UiDevice.exploreScreens() {
listOf("HOTTEST", "NEWEST", "SAVED").forEach { tag ->
waitForObject(By.res(tag)).click()
waitForIdle()
}
}
private fun UiDevice.waitForObject(selector: BySelector, timeout: Long = 10_000L): UiObject2 {
if (wait(Until.hasObject(selector), timeout)) {
return findObject(selector)
}
error("Object with selector [$selector] not found")
}
}
}

View file

@ -71,10 +71,6 @@ class SentryPlugin : Plugin<Project> {
telemetry.set(false)
telemetryDsn.set(null)
}
with(project.dependencies) {
addProvider("implementation", platform(libs.sentry.bom))
addProvider("implementation", libs.sentry.android)
}
}
}

View file

@ -16,12 +16,11 @@ import org.gradle.kotlin.dsl.exclude
/** Extension function to configure JUnit5 dependencies with the Truth assertion library. */
fun DependencyHandlerScope.addTestDependencies(project: Project) {
val libs = project.extensions.getByName("libs") as LibrariesForLibs
arrayOf("test", "androidTest", "screenshotTest")
arrayOf("test", "screenshotTest")
.filter { sourceSet -> project.configurations.findByName("${sourceSet}Implementation") != null }
.forEach { sourceSet ->
addProvider("${sourceSet}Implementation", platform(libs.junit.bom))
addProvider("${sourceSet}Implementation", libs.junit.jupiter.api)
addProviderConvertible("${sourceSet}Implementation", libs.junit.jupiter)
addProvider<MinimalExternalModuleDependency, ExternalModuleDependency>(
"${sourceSet}Implementation",
libs.truth,

View file

@ -47,14 +47,10 @@ dependencies {
implementation(libs.androidx.compose.material.icons.extended)
implementation(libs.androidx.compose.material3)
implementation(libs.androidx.compose.runtime)
implementation(libs.androidx.compose.runtime.saveable)
implementation(libs.androidx.compose.ui.text)
implementation(libs.androidx.core)
implementation(libs.coil3.compose)
implementation(libs.coil3.network.okhttp)
implementation(libs.compose.richtext.markdown)
implementation(libs.compose.richtext.material3)
implementation(libs.compose.richtext.ui)
implementation(libs.htmlconverter)
implementation(libs.kotlinx.collections.immutable)
implementation(libs.kotlinx.coroutines.core)

View file

@ -1,7 +1,6 @@
[versions]
aboutLibraries = "12.2.4"
agp = "8.12.0"
android-junit5 = "1.13.1.0"
coil3 = "3.3.0"
coroutines = "1.10.2"
dagger = "2.57"
@ -13,12 +12,10 @@ junit = "5.13.4"
konvert = "4.1.2"
kotlin = "2.2.0"
kotlinResult = "2.1.0"
leakcanary = "3.0-alpha-8"
lifecycle = "2.9.2"
navigation3 = "1.0.0-alpha06"
navigation3-material = "1.0.0-SNAPSHOT"
retrofit = "3.0.0"
richtext = "1.0.0-alpha03"
sentry-sdk = "8.18.0"
serialization = "1.9.0"
sqldelight = "2.1.0"
@ -39,13 +36,11 @@ androidx-compose-material-icons-extended = { module = "androidx.compose.material
androidx-compose-material3 = { module = "androidx.compose.material3:material3" }
androidx-compose-material3-window-size = { module = "androidx.compose.material3:material3-window-size-class" }
androidx-compose-runtime = { module = "androidx.compose.runtime:runtime" }
androidx-compose-runtime-saveable = { module = "androidx.compose.runtime:runtime-saveable" }
androidx-compose-ui = { module = "androidx.compose.ui:ui" }
androidx-compose-ui-text = { module = "androidx.compose.ui:ui-text" }
androidx-compose-ui-tooling = { module = "androidx.compose.ui:ui-tooling" }
androidx-compose-ui-tooling-preview = { module = "androidx.compose.ui:ui-tooling-preview" }
androidx-compose-ui-unit = { module = "androidx.compose.ui:ui-unit" }
androidx-compose-ui-util = { module = "androidx.compose.ui:ui-util" }
androidx-core = "androidx.core:core:1.16.0"
androidx-core-splashscreen = "androidx.core:core-splashscreen:1.2.0-rc01"
androidx-datastore = { module = "androidx.datastore:datastore-preferences", version.ref = "datastore" }
@ -56,7 +51,6 @@ androidx-navigation3-runtime = { module = "androidx.navigation3:navigation3-runt
androidx-navigation3-ui = { module = "androidx.navigation3:navigation3-ui", version.ref = "navigation3" }
androidx-paging-compose = "androidx.paging:paging-compose:3.3.6"
androidx-profileinstaller = "androidx.profileinstaller:profileinstaller:1.4.1"
androidx-test-uiautomator = "androidx.test.uiautomator:uiautomator:2.4.0-alpha05"
androidx-work-runtime = { module = "androidx.work:work-runtime", version.ref = "workmanager" }
build-agp = { module = "com.android.tools.build:gradle", version.ref = "agp" }
build-cachefix = "org.gradle.android.cache-fix:org.gradle.android.cache-fix.gradle.plugin:3.0.1"
@ -67,27 +61,21 @@ build-spotless = "com.diffplug.spotless:spotless-plugin-gradle:7.2.1"
build-vcu = "nl.littlerobots.version-catalog-update:nl.littlerobots.version-catalog-update.gradle.plugin:1.0.0"
coil3-compose = { module = "io.coil-kt.coil3:coil-compose", version.ref = "coil3" }
coil3-network-okhttp = { module = "io.coil-kt.coil3:coil-network-okhttp", version.ref = "coil3" }
compose-richtext-markdown = { module = "com.halilibo.compose-richtext:richtext-commonmark", version.ref = "richtext" }
compose-richtext-material3 = { module = "com.halilibo.compose-richtext:richtext-ui-material3", version.ref = "richtext" }
compose-richtext-ui = { module = "com.halilibo.compose-richtext:richtext-ui", version.ref = "richtext" }
dagger = { module = "com.google.dagger:dagger", version.ref = "dagger" }
dagger-compiler = { module = "com.google.dagger:dagger-compiler", version.ref = "dagger" }
eithernet = { module = "com.slack.eithernet:eithernet", version.ref = "eithernet" }
eithernet-integration-retrofit = { module = "com.slack.eithernet:eithernet-integration-retrofit", version.ref = "eithernet" }
eithernet-test-fixtures = { module = "com.slack.eithernet:eithernet-test-fixtures", version.ref = "eithernet" }
haze = { module = "dev.chrisbanes.haze:haze", version.ref = "haze" }
haze-materials = { module = "dev.chrisbanes.haze:haze-materials", version.ref = "haze" }
htmlconverter = "be.digitalia.compose.htmlconverter:htmlconverter:1.1.0"
javax-inject = "javax.inject:javax.inject:1"
jsoup = "org.jsoup:jsoup:1.21.1"
junit-bom = { module = "org.junit:junit-bom", version.ref = "junit" }
junit-jupiter = { module = "org.junit.jupiter:junit-jupiter" }
junit-jupiter-api = { module = "org.junit.jupiter:junit-jupiter-api" }
junit-jupiter-engine = { module = "org.junit.jupiter:junit-jupiter-engine" }
junit-platform-launcher = { module = "org.junit.platform:junit-platform-launcher" }
junit-legacy = "junit:junit:4.13.2"
konvert-annotations = { module = "io.mcarle:konvert-annotations", version.ref = "konvert" }
konvert-api = { module = "io.mcarle:konvert-api", version.ref = "konvert" }
konvert-processor = { module = "io.mcarle:konvert", version.ref = "konvert" }
kotlinResult = { module = "com.michael-bull.kotlin-result:kotlin-result", version.ref = "kotlinResult" }
kotlinResult-coroutines = { module = "com.michael-bull.kotlin-result:kotlin-result-coroutines", version.ref = "kotlinResult" }
@ -96,14 +84,12 @@ kotlinx-coroutines-core = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-c
kotlinx-coroutines-test = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-test", version.ref = "coroutines" }
kotlinx-serialization-core = { module = "org.jetbrains.kotlinx:kotlinx-serialization-core", version.ref = "serialization" }
kotlinx-serialization-json = { module = "org.jetbrains.kotlinx:kotlinx-serialization-json", version.ref = "serialization" }
leakcanary-android-test = { module = "com.squareup.leakcanary:leakcanary-android-test", version.ref = "leakcanary" }
napier = "io.github.aakira:napier:2.7.1"
okhttp-bom = "com.squareup.okhttp3:okhttp-bom:5.1.0"
okhttp-core = { module = "com.squareup.okhttp3:okhttp" }
okhttp-loggingInterceptor = { module = "com.squareup.okhttp3:logging-interceptor" }
retrofit = { module = "com.squareup.retrofit2:retrofit", version.ref = "retrofit" }
retrofit-kotlinxSerializationConverter = { module = "com.squareup.retrofit2:converter-kotlinx-serialization", version.ref = "retrofit" }
sentry-android = { module = "io.sentry:sentry-android", version.ref = "sentry-sdk" }
sentry-bom = { module = "io.sentry:sentry-bom", version.ref = "sentry-sdk" }
slack-compose-lints = "com.slack.lint.compose:compose-lint-checks:1.4.2"
slack-lints = "com.slack.lint:slack-lint-checks:0.11.0"
@ -119,7 +105,6 @@ unfurl = "me.saket.unfurl:unfurl:2.2.0"
[plugins]
aboutlibraries = { id = "com.mikepenz.aboutlibraries.plugin", version.ref = "aboutLibraries" }
android-junit5 = { id = "de.mannodermaus.android-junit5", version.ref = "android-junit5" }
android-lint = { id = "com.android.lint", version.ref = "agp" }
anvil = "com.squareup.anvil:2.6.1"
dependencyAnalysis = "com.autonomousapps.dependency-analysis:2.19.0"
@ -131,5 +116,4 @@ licensee = "app.cash.licensee:1.13.0"
modulegraphassert = "com.jraska.module.graph.assertion:2.9.0"
poko = "dev.drewhamilton.poko:0.19.3"
sqldelight = { id = "app.cash.sqldelight", version.ref = "sqldelight" }
tracelog = "dev.msfjarvis.tracelog:0.1.3"
whetstone = { id = "dev.msfjarvis.whetstone", version.ref = "whetstone" }

View file

@ -15,7 +15,6 @@ plugins {
dependencies {
compileOnly(libs.konvert.annotations)
api(projects.database.core)
implementation(libs.konvert.api)
implementation(libs.kotlinx.serialization.core)
ksp(libs.konvert.processor)