Syncronize local and remote Gradle cache

Is it possible to syncronize the local cache content with the remote cache without running the build/task?

I would need this, because my task is depending on another task’s result. This way if my task fails but the dependent was successful then the remote cache restores the dependent, which triggers that my task is not running.

Thanks in advance

Why does that trigger your task to not run?

I try to sum it in a nutshell:
a 3rd party plugin makes my task uncacheable hence I use the parent task’s run result to determine if my task should run.
My issue is that if the parent task is successful but my task fails then in the next run the parent task is taken from the cache hence not triggering my task.

Besides that this sounds like a very bad idea, how do you determine whether you task should run?

I add a doLast action to the parent task and use a flag to determine if that run.

That would fail even without the task result coming from the cache, it could for example also be up-to-date and thus not run.

You should really not do this.

And if you must, then you probably should create a build service that you register as OperationCompletionListener that can then record the outcome of the predecessor task and also see whether it came from cache or was up-to-date, and then use that service to determine whether your task should run.

I think I was ambigous, apols. I don’t need any output of the parent task.

“it could for example also be up-to-date and thus not run.”
This is exactly that I need - only run my task if the parent run.

What’s your problem then? If it is coming from cache it did not run, so your task not running is what you want according to what you just said.