Persisting an object instance across builds

Hi,
I’m currently working on a plugin for Scala.js, in collaboration with the main developer.

One of the build stage uses a linker and a cache, and he told me that they are incremental (~100x speedup after some builds), but it is only possible if they are kept alive across builds obviously.

SBT allows an object/value to be evaluated/stored only once at its startup (or when explicitely asked to change / reload), which means that the linker and cache can be then retrieved for each build, enabling this huge speedup.
I thought there was perhaps a way to give an object to the Gradle daemon (it wouldn’t work without one I guess) to be stored and retrieved later, but I haven’t find a way to do this.

So, I’m trying to create something like a global variable outside the builds, for a Gradle daemon (I guess). Anybody has an idea how to do it?

Sorry for my bad english, I hope I was clear enough, and thanks in advance!

Hi Guillaume,

the simplest solution would just be a static variable. Plugin/task classes are kept alive in the daemon.

A more sophisticated solution would be your own persistent cache which could even be reused by different daemons. There is no ready-to-reuse solution for this yet.

Cheers,
Stefan

Oh, I’m feeling a bit dumb right now, I didn’t even think about static variables… I tried to put it in the project.ext, among other things, but it didn’t work obviously.
Thanks a lot, it’s working like a charm !