How to print periodically in the console during a task

Hello, apparently our CI kills its Gradle process when there’s no logs printed for a while (10 mins).

Some tasks are lenghtly (R8 our Android app) and do not output stuff to the console for a while even if they are working under the hood.

For now, we are using the -i parameter to bloat our logs so the process isn’t killed.

I know the fix should be on the Circle CI part but, well, that’s Circle CI. If it’s cheap there’s a reason for that.

So I imagined I could print something to the console every minute during the R8 task so we could remove the -i parameter and finaly be able to read our logs in case of a problem.

But, well that’s Gradle for you, every search I did around this problem mentions a deprecated and / or removed API.

So, is there any way in Gradle 8 & 9 (and hopefully, later versions…) to print periodically to the console while a task (or a build, whatever) is running?

Thank you

I doubt there is a clean way, but you can probably do something like

val foo by tasks.registering {
    val trickCircleCi = AtomicBoolean(true)
    doFirst {
        thread(start = true) {
            while (trickCircleCi.get()) {
                sleep(1_000)
                logger.lifecycle("Dare you CircleCI!")
            }
        }
    }
    doLast {
        trickCircleCi.set(false)
    }
}

But it is probably much better to just tell CircleCI not to do that, for example using the no_output_timeout setting: https://support.circleci.com/hc/en-us/articles/360007188574-Build-has-Hit-Timeout-Limit