BuildListener settingsEvaluated callback doesn't work


I am using Gradle version 6.8.3 and I want to create a custom plugin that will measure the build duration (both per task and total duration). Something like GitHub - Skyscanner/gradle-time-logger-plugin: Gradle plugin to log your build time (BuildMeasurementTracker).

Both my plugin module and main project are located in the same repository.
Plugin modules are connected as includeBuild in the settings.gradle.
In my main project, I apply plugin by using apply plugin: ‘my-plugin-name’ in the build.gradle file.

Inside my plugin module, I created BuildExecutionListener that implements both BuildListener and TaskExecutionListener.

To measure the build start time I override beforeSettings function and initialize a buildStartTime variable in the BuildExecutionListener.
I also override buildFinished and calculate the elapsed time inside.

The problem is that beforeSettings is never called and buildStartTime is null. So I cannot measure the total build duration.

When I override projectsEvaluated the variable initialized as expected. However, the duration is not complete, because it doesn’t include the configuration phase.

Is there a way to measure total build time including the configuration phase?