Class ScanProgressReporter

java.lang.Object
com.arc_e_tect.gradle.gherkin.console.ScanProgressReporter

public final class ScanProgressReporter extends Object
Emits periodic, low-overhead 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

    Fields
    Modifier and Type
    Field
    Description
    static final int
    Default number of items between emitted status lines, absent an explicit override.
    static final long
    Default number of seconds between emitted status lines, absent an explicit override.
  • Constructor Summary

    Constructors
    Constructor
    Description
    ScanProgressReporter(org.gradle.api.logging.Logger logger, String phaseLabel, int total)
    Creates a reporter with the default throttle (every 50 items or every 2L seconds) and the real wall-clock time source.
    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 Type
    Method
    Description
    void
    Emits a final summary line unconditionally, regardless of throttling state - the last step() may have landed inside the throttle window, but this line is never suppressed.
    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.
    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.
    void
    Records one item processed, emitting a status line if the throttle window has elapsed.
    void
    step(String detail)
    Records one item processed, emitting a status line - with detail appended, when given - if the throttle window has elapsed.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • DEFAULT_EVERY_N_ITEMS

      public static final int DEFAULT_EVERY_N_ITEMS
      Default number of items between emitted status lines, absent an explicit override.
      See Also:
    • DEFAULT_EVERY_SECONDS

      public static final long DEFAULT_EVERY_SECONDS
      Default number of seconds between emitted status lines, absent an explicit override.
      See Also:
  • Constructor Details

    • ScanProgressReporter

      public ScanProgressReporter(org.gradle.api.logging.Logger logger, String phaseLabel, int total)
      Creates a reporter with the default throttle (every 50 items or every 2L seconds) and the real wall-clock time source. Prefer determinate(Logger, String, int) or indeterminate(Logger, String).
      Parameters:
      logger - the logger status lines are emitted to, at LIFECYCLE level
      phaseLabel - 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, at LIFECYCLE level
      phaseLabel - short label identifying the scan phase
      total - the total number of items expected, or a negative number for an indeterminate-total scan
      everyNItems - emit a status line at least this often, counted in processed items
      everySeconds - 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, at LIFECYCLE level
      phaseLabel - short label identifying the scan phase
      total - the total number of items expected; 0 is 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, at LIFECYCLE level
      phaseLabel - 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 to step(String) with no detail.
    • step

      public void step(String detail)
      Records one item processed, emitting a status line - with detail appended, 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; or null/blank for no detail
    • complete

      public void complete()
      Emits a final summary line unconditionally, regardless of throttling state - the last step() may have landed inside the throttle window, but this line is never suppressed. Safe to call on a reporter that never had step() called at all (the 0-items-processed case).