autonomousapps / dependency-analysis-gradle-plugin

Gradle plugin for JVM projects written in Java, Kotlin, Groovy, or Scala; and Android projects written in Java or Kotlin. Provides advice for managing dependencies and other applied plugins
Apache License 2.0
1.67k stars 115 forks source link

Reason id dependency filter ambiguity #1124

Closed seregamorph closed 4 months ago

seregamorph commented 4 months ago

Plugin version 1.29.0

Gradle version 8.6

JDK version 17

Describe the bug The reason task receives --id argument and filters dependency in a pretty lenient way. E.g. if the module has these dependencies:

and we call

./gradlew :module:reason --id list

if can pick any of those three modules (e.g. list-A). This depends on the combination of dependency scopes and order of definition.

Expected behavior

  1. If the name of the dependency is specified fully, it should be preferred.
  2. If there is am ambiguity and several dependencies match, it should throw exception instead of picking random first matching one

Additional context The problem is around these two places in the code:

To Reproduce Let me know if you need sample project to reproduce.

seregamorph commented 4 months ago

The solution proposed here: https://github.com/autonomousapps/dependency-analysis-gradle-plugin/pull/1125

autonomousapps commented 4 months ago

Thanks for the issue! This problem has annoyed me for a while, but I haven't had the bandwidth to focus on it. I appreciate the PR 👍

seregamorph commented 4 months ago

Addressed in https://github.com/autonomousapps/dependency-analysis-gradle-plugin/pull/1125