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

Lots of false positive under "Unused dependencies" : project doesn't compile anymore when removed

Open NinoDLC opened this issue 1 year ago • 1 comments
trafficstars

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)
  1. Follow advice, remove the 2 lines
  2. Rebuild (./gradlew :core-network:core-network:assembleDebug)
  3. 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

NinoDLC avatar Aug 01 '24 20:08 NinoDLC

Is that all of the advice? Or is there more, like used transitive advice?

autonomousapps avatar Aug 02 '24 23:08 autonomousapps

I'd guess this is because ignoring used transitive dependencies doesn't seem to be taken into account by the unused dependency reporting. In this case, the report states that a dependency is unused because the module is using a transitive but doesn't report the transitive info because it's turned off.

Would it be possible to update the unused dependency report to consider whether used transitives are ignored?

MJ-Hayden avatar Sep 11 '25 19:09 MJ-Hayden