I’ve have need of properties such as ‘build start time’, ‘build duration’, etc. If I had started + finished, I could of course calculate the duration… or with start and duration, calculate finished.
At any rate… where can I find this data? I know Gradle keeps track of such things, as evidenced by this output from a normal build:
Just setup your task dependencies so that getStartTime runs as the very first and printBuildData runs as the very last task. This should get you what you need. Please keep in mind that the output is in milliseconds so you will need to do some formatting to get a more human-recognizable output
Just FYI, your printBuildData would show the elapsed time between configuring getStartTime and configuring printBuildData. It wouldn’t include task execution or when the build actually finished.
Gradle has plenty of support for this type of info… try running a build with “–profile” command line switch.
Gradle creates a nicely formatted HTML page (in build/reports/profile) telling you all sorts of timing info, similar to this Summary (plus 3 more tabs of info):
Profile report
Profiled build: clean build uploadArchives
Started on: 2016/04/13 - 08:43:44
Description Duration
----------- --------
Total Build Time 15.378s
Startup 2.073s
Settings and BuildSrc 8.862s
Loading Projects 0.266s
Configuring Projects 1.492s
Task Execution 2.203s
I was hoping there’s a way to get to the data used to generate that page without forcing everyone to use --profile, especially since I need to get to it in a plugin… even if I could force --profile, I would then have to parse the HTML to get what I need. :-\