# Build config without drift-specific builders. When running a build in this directory, this file replaces build.yaml,
# which is what we want! Our builders depend on generated code, so they break the generated build script at the start of
# a build.
targets:
  analysis_results:
    # Analysis result serialization is drift-internal and doesn't need any of
    # the checks the default serialization builder runs on.
    auto_apply_builders: false
    sources:
      include:
        - "lib/src/analysis/**"
      exclude:
        - "lib/src/analysis/options.dart"
    builders:
      json_serializable:
        enabled: true
        options:
          checked: false
          disallow_unrecognized_keys: false
          any_map: true
          field_rename: snake
          explicit_to_json: true

      source_gen:combining_builder:
        enabled: false # Run in default target

  $default:
    dependencies: [":analysis_results"]
    builders:
      json_serializable:
        options:
          checked: true
          any_map: true
          disallow_unrecognized_keys: true
          field_rename: snake
          explicit_to_json: true
        generate_for:
          include: ["lib/src/analysis/options.dart"]
      # https://simonbinder.eu/posts/build_directory_moves/#generating-into-a-directory-with-source_gen
      source_gen:combining_builder:
        options:
          build_extensions:
            '^lib/src/{{}}.dart': 'lib/src/generated/{{}}.g.dart'
