When is Gradle.buildStarted called?

(Xavier Ducrohet) #1

I’m trying to listen the start/stop of a build. In my custom plugin’s apply() I’m doing:

project.gradle.buildStarted { }

project.gradle.buildFinished { }

The first closure is never called, the 2nd is after the build is done. Is it too late to listen to build start event? I’m trying to do something after the evaluation, but before the tasks are run (and only if they are run).

(Peter Niederwieser) #2

‘gradle.buildStarted’ is called too early for a plugin to register a listener in time. If you are interested in which tasks will be running, ‘gradle.taskGraph.whenReady’ might be what you are looking for.

(Xavier Ducrohet) #3

Seems to work thanks.