@@ -232,6 +232,61 @@ these options should be used rarely.
232232 and `applies_builder` to configure both ordering and ensure that steps are not
233233 skipped.
234234
235+ # # Triggers
236+
237+ Triggers are a performance heuristic that allow builders to quickly decide
238+ _not_ to run.
239+
240+ A builder runs only if triggered if the option `run_only_if_triggered` is
241+ `true`. This can be enabled for the builder :
242+
243+ ` ` ` yaml
244+ builders:
245+ my_builder:
246+ import: "package:my_package/builder.dart"
247+ builder_factories: ["myBuilder"]
248+ build_extensions: {".dart": [".my_package.dart"]}
249+ defaults:
250+ options:
251+ run_only_if_triggered: true
252+ ` ` `
253+
254+ Or, enabled/disabled in the `build.yaml` of the package applying the builder :
255+
256+ ` ` ` yaml
257+ targets:
258+ $default:
259+ builders:
260+ my_package:my_builder:
261+ options:
262+ run_only_if_triggered: true # or ` false`
263+ ```
264+
265+ Triggers are defined in a new top-level section called ` triggers ` :
266+
267+ ``` yaml
268+ triggers :
269+ my_package:my_builder :
270+ - import my_package/my_builder_annotation.dart
271+ ` ` `
272+
273+ An ` import` triggers says that the builder only runs if there is a direct import
274+ of the specified library. Usually, this will be a library that defines the
275+ annotation that configures the generator.
276+
277+ Triggers are collected from all packages in the codebase, not just packages
278+ defining or applying builders. This allows a package to provide new ways to
279+ trigger a builder from an unrelated package. For example, if
280+ ` third_party_package` re-exports the annotation in
281+ ` package:my_package/my_builder_annotation.dart` then it should also add a
282+ trigger :
283+
284+ ` ` ` yaml
285+ triggers:
286+ my_package:my_builder:
287+ - import third_party_package/annotations.dart
288+ ` ` `
289+
235290# Publishing `build.yaml` files
236291
237292` build.yaml` configuration should be published to pub with the package and
0 commit comments