autonomousapps/dependency-analysis-gradle-plugin

Kotlin removes unreachable bytecode causing DAGP to think a dependency is unused

オープン

#1,429 opened on 2025/04/30

 (5 件のコメント) (0 件のリアクション) (0 人の担当者)Kotlin (154 件のフォーク)auto 404
bughelp wantedsponsorabletoolchain:kotlin

Repository metrics

Stars
 (2,172 個のスター)
PR merge metrics
 (PR metrics pending)

説明

Plugin version 2.17.0

Gradle version 8.14

JDK version 17

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

Describe the bug Kotlin optimizes out unreachable bytecode like if (false) so if a usage of a dependency is inside of that block, DAGP considers it unused and will remove it. Removing it causes a compilation failure.

To Reproduce Steps to reproduce the behavior:

  1. In the attached project, :app:fixDependencies removes the dependency on :utils
  2. Running :app:assemble will have a compilation error because the dependency was removed

Expected behavior The :utils dependency should not be removed by fixDependencies and should be reported in build health as being used.

dagp-if-false-repro.zip

コントリビューターガイド