dependency-analysis-gradle-plugin
dependency-analysis-gradle-plugin copied to clipboard
Support the new Configuration Cache
Is your feature request related to a problem? Please describe. I'd like to enable the new configuration cache:
https://docs.gradle.org/6.7-rc-5/userguide/configuration_cache.html
but it has lots of problems with this plugin.
Describe the solution you'd like
It would be nice if there were no errors in this plugin when running gradle --configuration-cache
Additional context Obviously this is just a nice to have, everything works without it; just thought I'd put it on the radar.
I agree and would love to have this plugin support the configuration cache, but at the moment it's impossible. Some of the data the plugin needs to operate is not available in a conf-cache-friendly way. There are open issues on the Gradle issue tracker, but as far as I know, no eta on resolving them.
Stacktrace for reference
org.gradle.api.InvalidUserCodeException: Listener registration 'TaskExecutionGraph.addTaskExecutionListener' by org.gradle.execution.taskgraph.DefaultTaskExecutionGraph@167d2e92 is unsupported.
at org.gradle.configurationcache.initialization.DefaultConfigurationCacheProblemsListener.onBuildScopeListenerRegistration(ConfigurationCacheProblemsListener.kt:90)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:36)
at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:24)
at org.gradle.internal.event.DefaultListenerManager$ListenerDetails.dispatch(DefaultListenerManager.java:398)
at org.gradle.internal.event.DefaultListenerManager$ListenerDetails.dispatch(DefaultListenerManager.java:380)
at org.gradle.internal.event.AbstractBroadcastDispatch.dispatch(AbstractBroadcastDispatch.java:61)
at org.gradle.internal.event.DefaultListenerManager$EventBroadcast$ListenerDispatch.dispatch(DefaultListenerManager.java:368)
at org.gradle.internal.event.DefaultListenerManager$EventBroadcast.dispatch(DefaultListenerManager.java:179)
at org.gradle.internal.event.DefaultListenerManager$EventBroadcast.dispatch(DefaultListenerManager.java:153)
at org.gradle.internal.dispatch.ProxyDispatchAdapter$DispatchingInvocationHandler.invoke(ProxyDispatchAdapter.java:94)
at com.sun.proxy.$Proxy21.onBuildScopeListenerRegistration(Unknown Source)
at org.gradle.execution.taskgraph.DefaultTaskExecutionGraph.notifyListenerRegistration(DefaultTaskExecutionGraph.java:299)
at org.gradle.execution.taskgraph.DefaultTaskExecutionGraph.addTaskExecutionListener(DefaultTaskExecutionGraph.java:255)
at com.autonomousapps.DependencyAnalysisPlugin.apply(DependencyAnalysisPlugin.kt:104)
at com.autonomousapps.DependencyAnalysisPlugin.apply(DependencyAnalysisPlugin.kt:47)
@autonomousapps could you maybe link the upstream gradle issue?
@ZacSweers which version of the plugin are you on? I haven't used a task execution listener for a while.
When I'm at my desk I'll link the issue I was thinking about, but I suspect your issue is different.
0.61.0
Try 0.70.0?
For the record, this is the issue I filed against Gradle that prevents this plugin's execution from being fully conf-cache-ready. Please note that simply applying the plugin shouldn't break other aspects of the build: it's simply that the plugin's tasks will always require a full configuration until Gradle fixes the issue (which they have acknowledged they ought to do).
@ZacSweers it was v0.65.0 that removed that task execution listener.
0.70 reports no issues for us 👍
FYI, Gradle has told me they plan to make the results of dependency resolution available in a CC-friendly way sometime this year. So maybe by 2022 this plugin will be compatible :upside_down_face:
JFYI, version 0.77, got:
Configuration cache state could not be cached: field 'usedTransitiveComponents$delegate' from type 'com.autonomousapps.tasks.AdvicePerVariantTask': error writing value of type 'kotlin.UnsafeLazyImpl'
Configuration cache state could not be cached: field 'value' from type 'kotlin.InitializedLazyImpl': error writing value of type 'java.util.LinkedHashSet'
> Configuration cache state could not be cached: field 'dependency' from type 'com.autonomousapps.internal.TransitiveComponent': error writing value of type 'com.autonomousapps.advice.Dependency'
> Configuration cache state could not be cached: field 'group$delegate' from type 'com.autonomousapps.advice.Dependency': error writing value of type 'kotlin.SynchronizedLazyImpl'
> begin 0, end -1, length 10
@dsvoronin that issue could probably be resolved quickly. It probably isn't really worth it for that property to be lazy. If you want to open a PR, I think it's just a one-line change.
In general though, this plugin cannot be CC-compatible until Gradle provides a way to examine the resolved dependency graph in a compliant way.
@autonomousapps did you see this PR https://github.com/gradle/gradle/pull/18729? As far as i understand it should help
You're on top of things! That just got merged yesterday. It'll be in Gradle 7.4, and may require substantial changes to the plugin. No eta at this time.
Is there a way to just disable dependency analysis plugin until I need to use it? I guess I could just comment it out, right?
I just noticed (due to an ADS video that was released yesterday) that configuration cache tool is available in AS and it calls out this plugin. 😄
But I don't really use this plugin all the time, so maybe I can just comment it out.
The only solution at present is to comment it out. I don't have any plans to make it possible to, e.g., "disable" it. I'd rather just make it compliant as soon as it's practical to do so.
Cool. No worries. Just checking. Cheers Tony
gradle/gradle#18729 won't be in 7.4, it needs more work and is being reverted for now in gradle/gradle#19119.
Thanks for letting me know, @eskatos!
Found two other issues related to configuration cache
Task
:XYZ:findDeclaredProcsMain
of typecom.autonomousapps.tasks.FindDeclaredProcsTask
: cannot serialize object of type 'com.autonomousapps.services.InMemoryCache', a subtype of 'org.gradle.api.services.BuildService', as these are not supported with the configuration cache.
Task
:XYZ:graphViewMain
of typecom.autonomousapps.tasks.GraphViewTask
: cannot serialize object of type 'org.gradle.api.internal.artifacts.configurations.DefaultConfiguration', a subtype of 'org.gradle.api.artifacts.Configuration', as these are not supported with the configuration cache.
FYI - Additional to @mvegter issues, I'm also seeing this one using 0.80.0
version and Gradle 7.4
:
Task
:XYZ:locateDependenciesDebug
of typecom.autonomousapps.tasks.LocateDependenciesTask
: cannot serialize object of type 'org.gradle.api.internal.artifacts.configurations.DefaultConfigurationContainer', a subtype of 'org.gradle.api.artifacts.ConfigurationContainer', as these are not supported with the configuration cache.
https://github.com/autonomousapps/dependency-analysis-android-gradle-plugin/pull/680 resolves https://github.com/autonomousapps/dependency-analysis-android-gradle-plugin/issues/306#issuecomment-1045985505
https://github.com/autonomousapps/dependency-analysis-android-gradle-plugin/issues/306#issuecomment-1048848550 is not an issue since 1.0.
Will release the partial support as 1.2.2.
Ended up releasing as 1.3.0, since there was a new feature as well.
Testing Gradle 8.1 RC1, which promotes the configuration cache to stable:
- If I run
buildHealth
withorg.gradle.configuration-cache=true
in 'gradle.properties', all is well. - If I add
org.gradle.configuration-cache.problems=warn
,buildHealth
fails with the following:
Execution failed for task ':di-with-koin:graphViewTest'.
> lateinit property compileClasspath has not been initialized
Reproducer with org.gradle.configuration-cache.problems=warn
currently set: https://github.com/sdkotlin/sd-kotlin-talks/tree/gradle-8.1 (specifically, https://github.com/sdkotlin/sd-kotlin-talks/tree/73c97f04b1bbbe361ea6c51ae1886f70e208bfa0).
Filed #885 for the issue described above (with reference to the possibly related gradle/gradle#24636).
Just tried on one of my projects with version 1.14.1 and the latest one at the moment i.e. 1.20.0 No issues with storing configuration cache but it still does end up discarding it every time
0 problems were found storing the configuration cache.
See the complete report at file:///Users/<username>/buildHealth/<project-name>/build/reports/configuration-cache/c9rypw15z23d3mxbpt39glbci/9vgbv9endq14ao2zoc6mlt1j9/configuration-cache-report.html
BUILD SUCCESSFUL in 11s
145 actionable tasks: 116 executed, 17 from cache, 12 up-to-date
Publishing build scan...
Configuration cache entry discarded. // <-----------
Curious why it is being discarded even it says 0 problems found storing the cache? Something under the hood? Thanks
@vicky17d discard happens when a task calls Task.notCompatibleWithConfigurationCache(cause)
. See also https://github.com/gradle/gradle/issues/24636#issuecomment-1496255070 for more details.
Another configuration cache related thing with Gradle 8.1.1, there seems to be a lot of file system access at configuration time. For any project I see this in the config cache report:
It's not that bad but it adds up to thousands or tens of thousands of inputs that Gradle needs to keep track of in big projects
Can somebody tell me if this is still blocked by gradle or is there a way forward? If it is waiting on Gradle has an issue been filed with them? It seems that Gradle 7.5 should have all the necessary features: https://gradle-community.slack.com/archives/C013WEPGQF9/p1688473669175499?thread_ts=1688469548.868469&cid=C013WEPGQF9
I think this is not blocked anymore. Gradle now allows resolution results as task inputs. It's sometimes a bit tedious to figure out how to use it correctly, but it works.
This issue just™️ needs to be done now.
(Hint: I think @autonomousapps would be happy to work on this if someone would sponsor the work 😉)
Thanks @jjohannes Just curious if payment for one feature is an option and what would that cost?