build method

  1. @override
Future<void> build(
  1. BuildStep buildStep
)

Generates the outputs for a given BuildStep.

Implementation

@override
Future<void> build(BuildStep buildStep) async {
  final library = await buildStep.inputLibrary;
  final annotatedElements = _findAnnotatedElements(library);

  if (annotatedElements.isEmpty) {
    return;
  }

  try {
    final schemaContent =
        await _generateSchemaContent(annotatedElements, buildStep);

    if (schemaContent.isEmpty) {
      return;
    }

    await _writeSchemaFiles(buildStep, schemaContent);
  } on Exception catch (e, stackTrace) {
    log.severe('Failed to generate schema for ${buildStep.inputId.path}', e,
        stackTrace);
    rethrow;
  }
}