Open ivanalvarado opened 2 years ago
Thanks for the issue. I'm a bit on the fence as to whether this is a bug or a feature request :) I'll certainly consider whether some improvement could be made in this area.
Thanks for the issue. I'm a bit on the fence as to whether this is a bug or a feature request :) I'll certainly consider whether some improvement could be made in this area.
Thanks for considering this. In the meantime, we've got a workaround where we apply a plugin configuration in the failing module like the following:
apply plugin: "com.android.library"
apply plugin: "kotlin-android"
apply plugin: "kotlin-kapt"
...
dependencies {
kapt 'com.google.dagger:hilt-android-compiler:2.43.2'
...
implementation 'com.google.dagger:hilt-android:2.43.2'
}
// Dependency Analysis returns the kotlin-kapt could be removed. However the test execution fails(kapt used in test
// implementation. Ignoring manually.
dependencyAnalysis {
issues {
onAny {
severity('fail')
exclude('kotlin-kapt')
}
}
}
Is your feature request related to a problem? Please describe.
The plugin is raising an error that the
kapt
plugin is unused even when it's applied to an excluded unused dependency in a gradle project.For example, in this project our dependency analysis plugin is configured to not fail if
'com.google.dagger:hilt-android-compiler'
is unused for annotation processors:build-configuration/project-health.gradle
In the
mylibrary/build.gradle
we have'com.google.dagger:hilt-android-compiler:2.43.2'
configured withkapt
:When we run dependency analysis plugin by doing
./gradlew :mylibrary:projectHealth
, the plugin correctly excludes'com.google.dagger:hilt-android-compiler'
from being reported as an unused annotation processor, but raises that thekapt
plugin was applied but no annotation processors were used:Describe the solution you'd like
We expect the plugin to detect that
'com.google.dagger:hilt-android-compiler'
is excluded and because it's using thekapt
plugin, the plugin shouldn't be reported as unused.Describe alternatives you've considered
We are able to add a workaround for now by excluding
kotlin-kapt
as a redundant plugin in the dependency analysis configuration. However, we feel this is a bit aggressive:Additional context
We assume that the plugin is detecting that because
'com.google.dagger:hilt-android-compiler'
is unused and configured withkapt
, then it effectively detects thekapt
plugin as unused as well and thus raises this as an error.We've create a project that easily reproduces this behavior: https://github.com/ivanalvarado/Dependency-Analysis-Plugin-Repro Simply run
./gradlew :mylibrary:projectHealth
and observe the failure.