Package org.gradle.api.flow
Interface FlowProviders
-
@Incubating public interface FlowProviders
Exposes build lifecycle events asproviders
so they can be used as inputs todataflow actions
.- Since:
- 8.1
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description Provider<BuildWorkResult>
getBuildWorkResult()
Returns aprovider
for the summary result of the execution of the work scheduled for the current build.
-
-
-
Method Detail
-
getBuildWorkResult
Provider<BuildWorkResult> getBuildWorkResult()
Returns aprovider
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
-
-