Class ScanProgressReporter
LIFECYCLE-level status lines for a long-running scan loop
(feature file reindexing, feature file parsing, glue code scanning, ...), so a consumer watching
the build knows the task is still alive and roughly how far along it is.
Deliberately built only on the public Logger API - one plain line per status update,
never overwriting a line in place - rather than Gradle's internal, unsupported rich-console
single-line progress indicator. This plugin is published to the Gradle Plugin Portal for
consumers on Gradle versions this codebase doesn't control; the internal progress API has
changed shape across versions and offers no compatibility guarantee. This is a deliberate
trade-off in exchange for forward/backward compatibility, not an oversight.
A status line is emitted every everyNItems items or every
everySeconds seconds since the last emission, whichever comes first - never on every
single item, and never silent for more than everySeconds regardless of how many items
are processed in between. complete() always emits a final summary line, even if the
most recent step() landed inside the throttle window - the final line is never
suppressed by throttling.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intDefault number of items between emitted status lines, absent an explicit override.static final longDefault number of seconds between emitted status lines, absent an explicit override. -
Constructor Summary
ConstructorsConstructorDescriptionScanProgressReporter(org.gradle.api.logging.Logger logger, String phaseLabel, int total) ScanProgressReporter(org.gradle.api.logging.Logger logger, String phaseLabel, int total, int everyNItems, long everySeconds) Creates a reporter with an explicit throttle and the real wall-clock time source. -
Method Summary
Modifier and TypeMethodDescriptionvoidcomplete()Emits a final summary line unconditionally, regardless of throttling state - the laststep()may have landed inside the throttle window, but this line is never suppressed.static ScanProgressReporterdeterminate(org.gradle.api.logging.Logger logger, String phaseLabel, int total) Creates a reporter for a scan whose total item count is known ahead of time.static ScanProgressReporterindeterminate(org.gradle.api.logging.Logger logger, String phaseLabel) Creates a reporter for a scan whose total item count isn't known ahead of time.voidstep()Records one item processed, emitting a status line if the throttle window has elapsed.voidRecords one item processed, emitting a status line - withdetailappended, when given - if the throttle window has elapsed.
-
Field Details
-
DEFAULT_EVERY_N_ITEMS
public static final int DEFAULT_EVERY_N_ITEMSDefault number of items between emitted status lines, absent an explicit override.- See Also:
-
DEFAULT_EVERY_SECONDS
public static final long DEFAULT_EVERY_SECONDSDefault number of seconds between emitted status lines, absent an explicit override.- See Also:
-
-
Constructor Details
-
ScanProgressReporter
Creates a reporter with the default throttle (every 50 items or every 2L seconds) and the real wall-clock time source. Preferdeterminate(Logger, String, int)orindeterminate(Logger, String).- Parameters:
logger- the logger status lines are emitted to, atLIFECYCLElevelphaseLabel- short label identifying the scan phase, e.g."Parsing feature files"total- the total number of items expected, or a negative number for an indeterminate-total scan (the total isn't known ahead of time)
-
ScanProgressReporter
public ScanProgressReporter(org.gradle.api.logging.Logger logger, String phaseLabel, int total, int everyNItems, long everySeconds) Creates a reporter with an explicit throttle and the real wall-clock time source.- Parameters:
logger- the logger status lines are emitted to, atLIFECYCLElevelphaseLabel- short label identifying the scan phasetotal- the total number of items expected, or a negative number for an indeterminate-total scaneveryNItems- emit a status line at least this often, counted in processed itemseverySeconds- emit a status line at least this often, counted in elapsed seconds since the last emission
-
-
Method Details
-
determinate
public static ScanProgressReporter determinate(org.gradle.api.logging.Logger logger, String phaseLabel, int total) Creates a reporter for a scan whose total item count is known ahead of time. Emitted lines include a running fraction and percentage, e.g."Parsing feature files: 150/438 (34%)".- Parameters:
logger- the logger status lines are emitted to, atLIFECYCLElevelphaseLabel- short label identifying the scan phasetotal- the total number of items expected;0is valid and not an error- Returns:
- a new determinate-mode reporter, using the default throttle
-
indeterminate
public static ScanProgressReporter indeterminate(org.gradle.api.logging.Logger logger, String phaseLabel) Creates a reporter for a scan whose total item count isn't known ahead of time. Emitted lines report only a running count, e.g."Scanning glue code: 27 processed so far".- Parameters:
logger- the logger status lines are emitted to, atLIFECYCLElevelphaseLabel- short label identifying the scan phase- Returns:
- a new indeterminate-mode reporter, using the default throttle
-
step
public void step()Records one item processed, emitting a status line if the throttle window has elapsed. Equivalent tostep(String)with no detail. -
step
Records one item processed, emitting a status line - withdetailappended, when given - if the throttle window has elapsed.- Parameters:
detail- short description of the current item, appended to the line only when this call itself results in an emission; ornull/blank for no detail
-
complete
public void complete()
-