autonomousapps / autonomousapps/dependency-analysis-gradle-plugin

When used-transitive-dependencies (add) advice is disabled, then unused-dependencies (remove) advice is not safe to follow. Consider clarifying this in the build/project health output.

Open
#1,232 2 comments 3 reactions 0 assignees View on GitHub
enhancement sponsorable
Dominant language
Kotlin
Stars
2.2k
Forks
158
Avg merge
16h 25m
Merged PRs (30d)
46

Description

**Build scan link**
https://scans.gradle.com/s/wrruxaf2etxw2 (not working because I've removed the dependency as hinted by the plugin)
https://scans.gradle.com/s/3stvxpgsu6fqc (working with the dependency back)

**Plugin version**
1.32.0

**Gradle version**
8.6

**JDK version**
17

**(Optional) Kotlin and Kotlin Gradle Plugin (KGP) version**
Kotlin : 1.9.24

**(Optional) Android Gradle Plugin (AGP) version**
AGP : 8.2.2

**(Optional) `reason` output for bugs relating to incorrect advice**
`./gradlew :core-network:core-network:reason --id com.jakewharton.threetenabp:threetenabp:1.3.1`
```
> Task :core-network:core-network:reason

----------------------------------------
You asked about the dependency 'com.jakewharton.threetenabp:threetenabp:1.3.1 (libs.threetenabp)'.
You have been advised to remove this dependency from 'implementation'.
----------------------------------------

Shortest path from :core-network:core-network to com.jakewharton.threetenabp:threetenabp:1.3.1 (libs.threetenabp) for debugCompileClasspath:
:core-network:core-network
\--- com.jakewharton.threetenabp:threetenabp:1.3.1

Shortest path from :core-network:core-network to com.jakewharton.threetenabp:threetenabp:1.3.1 (libs.threetenabp) for debugRuntimeClasspath:
:core-network:core-network
\--- com.jakewharton.threetenabp:threetenabp:1.3.1

Shortest path from :core-network:core-network to com.jakewharton.threetenabp:threetenabp:1.3.1 (libs.threetenabp) for debugUnitTestCompileClasspath:
:core-network:core-network
\--- com.jakewharton.threetenabp:threetenabp:1.3.1

Shortest path from :core-network:core-network to com.jakewharton.threetenabp:threetenabp:1.3.1 (libs.threetenabp) for debugUnitTestRuntimeClasspath:
:core-network:core-network
\--- com.jakewharton.threetenabp:threetenabp:1.3.1

Shortest path from :core-network:core-network to com.jakewharton.threetenabp:threetenabp:1.3.1 (libs.threetenabp) for debugAndroidTestCompileClasspath:
:core-network:core-network
\--- com.jakewharton.threetenabp:threetenabp:1.3.1

Shortest path from :core-network:core-network to com.jakewharton.threetenabp:threetenabp:1.3.1 (libs.threetenabp) for debugAndroidTestRuntimeClasspath:
:core-network:core-network
\--- com.jakewharton.threetenabp:threetenabp:1.3.1

Shortest path from :core-network:core-network to com.jakewharton.threetenabp:threetenabp:1.3.1 (libs.threetenabp) for releaseCompileClasspath:
:core-network:core-network
\--- com.jakewharton.threetenabp:threetenabp:1.3.1

Shortest path from :core-network:core-network to com.jakewharton.threetenabp:threetenabp:1.3.1 (libs.threetenabp) for releaseRuntimeClasspath:
:core-network:core-network
\--- com.jakewharton.threetenabp:threetenabp:1.3.1

Shortest path from :core-network:core-network to com.jakewharton.threetenabp:threetenabp:1.3.1 (libs.threetenabp) for releaseUnitTestCompileClasspath:
:core-network:core-network
\--- com.jakewharton.threetenabp:threetenabp:1.3.1

Shortest path from :core-network:core-network to com.jakewharton.threetenabp:threetenabp:1.3.1 (libs.threetenabp) for releaseUnitTestRuntimeClasspath:
:core-network:core-network
\--- com.jakewharton.threetenabp:threetenabp:1.3.1

Source: debug, main
-------------------
(no usages)

Source: release, main
---------------------
(no usages)

Source: debug, test
-------------------
(no usages)

Source: release, test
---------------------
(no usages)

Source: debug, android_test
---------------------------
(no usages)

BUILD SUCCESSFUL in 18s
```

**Describe the bug**

**To Reproduce**
Steps to reproduce the behavior:
1. Use `./gradlew buildHealth`
2. Get advice :
```
Advice for :core-network:core-network
Unused dependencies which should be removed:
implementation(libs.rxjava2.rxjava)
implementation(libs.threetenabp)
```
3. Follow advice, remove the 2 lines
4. Rebuild (`./gradlew :core-network:core-network:assembleDebug`)
5. Build fails :
```
> Task :core-network:core-network:compileDebugKotlin FAILED
e: file:///C:/Work/lapresse/LaPresse/core-network/core-network/src/main/kotlin/org/openapitools/client/infrastructure/LocalDateAdapter.kt:8:12 Unresolved reference: threeten
(...)
```

**Expected behavior**
Build should not fail after follow an advice

Contributor guide

Open the contributing guide

Research direction

Reproduce the issue with ./gradlew buildHealth and :core-network:core-network:assembleDebug using the versions and dependency advice shown. Inspect how build/project health output handles unused-dependency advice when used-transitive-dependencies advice is disabled. Done means the output clearly warns that following the removal advice may be unsafe, and the reported build scenario is covered.

Written by the indexing model from the issue text.

Assessment

Tech stack
kotlin
Domain
build-system, devtools
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.