dependency-analysis-gradle-plugin icon indicating copy to clipboard operation
dependency-analysis-gradle-plugin copied to clipboard

Detect and fix when a dependency is in both implementation and api

Open JakeWharton opened this issue 4 months ago • 1 comments

There's the simple case of the same coordinates declared in both configurations.

The case I just fixed was more complex as it was two different version catalog entries:

[versions]
foundationLayout = "1.8.3"

[libraries]
compose-bom = { module = "androidx.compose:compose-bom", version = "2025.08.00" }
composeUi-foundation-layout = { module = "androidx.compose.foundation:foundation-layout" }

androidx-foundation-layout = { group = "androidx.compose.foundation", name = "foundation-layout", version.ref = "foundationLayout" }
dependencies {
  api platform(libs.compose.com)
  api libs.composeUi.foundation.layout

  implementation libs.androidx.foundation.layout
}

JakeWharton avatar Aug 21 '25 01:08 JakeWharton

The plugin works by looking at the "raw identifier" (the string), only rendering with the version catalog entry, so I'd expect that addressing this will also address the more complex case where there might be multiple version catalog entries that point to the same thing. Note that the plugin currently has no support for removing things from the version catalog.

We have an internal tool (at Cash) built on top of this which can rewrite version catalogs, but it relies on an internal library we haven't yet open sourced.

autonomousapps avatar Aug 28 '25 22:08 autonomousapps