Change theme
Help
Press space for more information.
Show links for this issue (Shortcut: i, l)
Copy issue ID
Previous Issue (Shortcut: k)
Next Issue (Shortcut: j)
Sign in to use full features.
Vote: I am impacted
Notification menu
Refresh (Shortcut: Shift+r)
Go home (Shortcut: u)
Pending code changes (auto-populated)
[ID: 558956]
View issue level access limits(Press Alt + Right arrow for more information)
Unintended behavior
View staffing
Description
Currently the AGP artifact dependencies list ASM and a few other dependencies.
I'm guessing this is to support APIs such as that accept an
Component.transformClassesWith()
AsmClassVisitorFactory
.While this is convenient, this also pollutes the main build classpath. If 2 different plugins want to use different versions of ASM, this is problematic.
Having bumped into this problem several times now, I now believe that a good solution would be for task actions to run in separate classloaders. This way the plugin wiring code can stay relatively "pure" of external dependencies and avoid clashes. This would be a way to effectively achieve plugin isolation without requiring specific support from Gradle. Just run your work in different classloaders.
For APIs such as
Component.transformClassesWith()
, they could be migrated to some kind ofServiceLoader
API, like KSP is doing with KSP processors. This is a bit more work for the user but it is also advanced use cases so I think it's worth it. It plays also better with incremental compilation because changing a processor wouldn't invalidate the whole build anymore.I understand this is no trivial task but still thought I'd open this to gather interest and see if this would be a desired future to pursue.