New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Incorrect advice to change dependency from implementation to api #1118
Comments
Thanks for the issue. This is an interesting bug. I don't have any immediate ideas how to resolve it -- open to suggestions. |
I've found a similar case in my Java multi module library. Example:
and after running ./gradlew buildHealth I get
I don't understand why plugin tries to change implementation to api in such a case. Plugin has no idea about the subsequent usages of the library, so the advice is more harmful than useful, isn't it? 😢 Is it possible to disable such advice (from impl to api) via configuration?
|
@Natoshka yours is a very different case, and I see no bug. Note this text in your
Please see this. |
@autonomousapps WOW! Thanks for such insight! It seems I have been using Gradle wrong 😳 And thanks for plugin, by the way ❤️ |
If I understand correctly, this behavior happens due to analyze of some compiler-generated classes, for example for lambdas. For test project Kotlin bytecode tool-window shows this:
So, may be add some exclusion option like
|
Thanks! Not a bad idea. Can you use the existing DSL to add the exclusions you'd need? |
Yes, it is possible, but you have to manually add all files where this happens. The easiest way - is to exclude via |
Plugin version
"1.29.0"
Gradle version
Gradle-8.2
JDK version
openjdk version "17" 2021-09-14
OpenJDK Runtime Environment (build 17+35-2724)
OpenJDK 64-Bit Server VM (build 17+35-2724, mixed mode, sharing)
(Optional) Kotlin and Kotlin Gradle Plugin (KGP) version
"1.9.0"
(Optional) Android Gradle Plugin (AGP) version
8.2.0
(Optional)
reason
output for bugs relating to incorrect adviceDescribe the bug
As per this article: https://dev.to/autonomousapps/dependency-analysis-gradle-plugin-what-s-an-abi-3l2h this plugin uses application binary interface as a source of advices. Unfortunately, compiler can add some optimizations, such as cache for lambdas:
And due to these transformations it is possible, that some classes will be treated as exposed (
BoxScope
from steps to reproduce section), but in fact they are not a part of actual public module API.To Reproduce
Steps to reproduce the behavior:
uikit
with compose elements for android development.It exposes
BoxScope
, hence hasapi("androidx.compose.foundation:foundation-layout-android")
2) Create
feature
module and useuikit
as a dependency:This module doesn't expose BoxScope directly, just uses it internally, but plugin treats it as public usage.
Expected behavior
Plugin shouldn't advice to change from
implementation("androidx.compose.foundation:foundation-layout-android")
toapi("androidx.compose.foundation:foundation-layout-android")
forfeature
module.Additional context
Test project: DependencyAnalysisTest.zip (don't forget to add
local.properties
withsdk.dir=YOUR_PATH
)Launch the
projectHealth
task forfeature
moduleand check reason:
The text was updated successfully, but these errors were encountered: