Is it ever acceptable to use static variables in a Gradle plugin to cache data between build invocations when using the daemon?
This issue suggests plugins should avoid static state, but is this always true?
- A plugin modifies a project’s dependency tree during dependency resolution, using a small amount of data from the POM files of the project’s dependencies (the exclusions).
- Parsing these files slows down dependency resolution
A small (~10KB) cache using a static variable in the plugin could greatly speed up dependency resolution on subsequent builds when using the Gradle daemon. (I cannot find any Gradle API that would assist in this. Plugin uses Gradle 2.X API).
Is a static variable in the plugin acceptable in this scenario? Are there any docs on the implications of using static state?
I understand the cache might get duplicated by being loaded on multiple classloaders, but this seems acceptable if the cache is capped at a very small size.