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

Generated advice does not use version catalog aliases when DAGP is applied as settings plugin

Open timoloewe opened this issue 6 months ago • 1 comments

Plugin version

2.17.0

Gradle version

8.12

JDK version

21

(Optional) Kotlin and Kotlin Gradle Plugin (KGP) version

2.1.20

Describe the bug

When applying DAGP via the build-health settings plugin, the generated advice does not use the dependency aliases from the Gradle version catalog. When applying DAGP via the dependency-analysis plugin to the root project (and subprojects), the version catalog aliases are used as expected.

To Reproduce Steps to reproduce the behavior:

  1. Add the build-health plugin to settings.gradle.kts as described here.
  2. Add an unused dependency from the version catalog to one of the modules. E.g. implementation(libs.okhttp).
  3. The plugin generates the following advice:
Unused dependencies which should be removed:
  implementation("com.squareup.okhttp3:okhttp:4.12.0")

Expected behavior

The plugin should generate the advice using the dependency alias from the version catalog:

Unused dependencies which should be removed:
  implementation(libs.okhttp)

This is working as expected in the exact same project when applying DAGP via the root project plugin (as described here) instead of the settings plugin.

Additional context

I'm unsure if this is related to the fact that Gradle version catalogs are not available to settings plugins. I assumed, though, that this would work the same no matter how the plugin is applied, so it's unexpected behavior to me.

I've created a simple reproducer: dagp-catalog-repro.zip

timoloewe avatar May 12 '25 10:05 timoloewe

Thanks for the report and reproducer.

autonomousapps avatar May 15 '25 23:05 autonomousapps

Looks to be the same for typesafe project accessors - should I open a new issue for that?

3flex avatar Aug 02 '25 04:08 3flex

Looks to be the same for typesafe project accessors - should I open a new issue for that?

do you mean specifically for the settings plugin? If so, yes please create a new issue.

autonomousapps avatar Aug 02 '25 19:08 autonomousapps

https://github.com/autonomousapps/dependency-analysis-gradle-plugin/blob/main/CHANGELOG.md#version-351

autonomousapps avatar Nov 26 '25 19:11 autonomousapps