Skip to content

Instantly share code, notes, and snippets.

@ring2003
Forked from nikos/GradleTaskTimer.gradle
Created May 19, 2021 06:14
Show Gist options
  • Select an option

  • Save ring2003/c701c8d94cc331f2e620acd5cd78f8c4 to your computer and use it in GitHub Desktop.

Select an option

Save ring2003/c701c8d94cc331f2e620acd5cd78f8c4 to your computer and use it in GitHub Desktop.
Measure time for the execution of each gradle task executed
class TaskTimerListener implements TaskExecutionListener {
private Clock clock
@Override
void beforeExecute(Task task) {
clock = new org.gradle.util.Clock()
}
@Override
void afterExecute(Task task, TaskState taskState) {
task.project.logger.info "Execution of ${task.name} took ${clock.time}"
}
}
gradle.addListener new TaskTimerListener()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment