How do I capture build time at the end of a build?


(iwarpter) #1

I am using the gradle.buildFinished hook to capture various metrics at the end of a gradle build is it possible to capture the total time?

Simplified example:

gradle.buildFinished { buildResult ->
 println "Tasks: " + tasks
 println "Version: " + version
 println "Plugins: " + plugins
 println "Total time: " + time
}

Obviously time isnt a gradle project property, but i’m not sure how to get the total time.


(Peter Niederwieser) #2

You can use ‘gradle.buildStarted’ together with ‘gradle.buildFinished’ to get the total time.


(iwarpter) #3

Can you provide a quick snippet for this? I tried using gradle.buildStarted but couldnt get it to invoke I read the post http://stackoverflow.com/questions/19165317/gradle-buildstarted-not-triggered regarding this and the use of the Gradle.addBuildListener but still come up empty.