buildExtensions property

  1. @override
Map<String, List<String>> get buildExtensions

Mapping from input file extension to output file extensions.

All input sources matching any key in this map will be passed as a build step to this builder. Only files with the same basename and an extension from the values in this map are expected as outputs.

  • If an empty key exists, all inputs are considered matching.
  • An instance of a builder must always return the same configuration. Typically, a builder will return a const map. Builders may also choose extensions based on BuilderOptions.
  • Most builders will use a single input extension and one or more output extensions.

TODO(davidmorgan): add examples.

Implementation

@override
Map<String, List<String>> get buildExtensions {
  final inputToOutputMap = <String, List<String>>{};
  if (config.schemaId != null) {
    // buildExtensions already include the 'lib' path segment, so we must remove it here
    inputToOutputMap[r'$lib$'] = [
      p.joinAll(pathSegments(config.schemaId!).skip(1))
    ];
  }

  if (config.schemaIds != null) {
    for (final schemaId in config.schemaIds!) {
      inputToOutputMap[schemaId.path] = [p.joinAll(pathSegments(schemaId))];
    }
  }

  return inputToOutputMap;
}