Package org.gradle.api.flow

# Interface FlowProviders

@Incubating @ServiceScope(org.gradle.internal.service.scopes.Scope.Build.class) public interface FlowProviders
Exposes build lifecycle events as `providers` so they can be used as inputs to `dataflow actions`.

Since:
  8.1

- ## Method Summary

  Modifier and Type
  Method
  Description
  `Provider<BuildWorkResult>`
  `getBuildWorkResult()`
  Returns a `provider` for the summary result of the execution of the work scheduled for the current build.

- ## Method Details

  - ### getBuildWorkResult

    Provider<BuildWorkResult> getBuildWorkResult()
    Returns a `provider` for the summary result of the execution of the work scheduled for the current build.

    The returned `provider's value` becomes available after the scheduled work has completed - successfully or otherwise - or after a configuration phase failure prevents execution.

    IMPORTANT: trying to access the provider's value before the scheduled work has finished will result in an error.

         /**
          * A settings plugin that plays an appropriate sound at the end of a build.
          */
         class SoundFeedbackPlugin implements Plugin<Settings> {

             private final FlowScope flowScope;
             private final FlowProviders flowProviders;

             @Inject
             SoundFeedbackPlugin(FlowScope flowScope, FlowProviders flowProviders) {
                 this.flowScope = flowScope;
                 this.flowProviders = flowProviders;
             }

             @Override
             public void apply(Settings target) {
                 final File soundsDir = new File(target.getSettingsDir(), "sounds");
                 flowScope.always(FFPlay.class, spec ->
                     spec.getParameters().getMediaFile().fileProvider(
                         flowProviders.getBuildWorkResult().map(result ->
                             new File(
                                 soundsDir,
                                 result.getFailure().isPresent() ? "sad-trombone.mp3" : "tada.mp3"
                             )
                         )
                     )
                 );
             }
         }

    See Also:
      - `FlowAction`
      - `FlowScope`