smotastic / smartstruct

Dart Code Generator for generating mapper classes
35 stars 20 forks source link

Unable to generate files in different directories #54

Closed andrew-tpz closed 2 years ago

andrew-tpz commented 2 years ago

Maybe this can help: https://github.com/dart-lang/source_gen/tree/master/source_gen#generating-files-in-different-directories

smotastic commented 2 years ago

Hi andrew,

so the idea is to make it configurable (via environments?) where the generated files will be placed? If the yaml is also able to read environments, this should be fairly easy to implement by adding the location in the generator/build.yaml

andrew-tpz commented 2 years ago

Hi, I can set output folder for json_serializable and freezed by adding build.yaml to my project:

targets:
  $default:
    builders:
      source_gen|combining_builder:
        options:
          build_extensions:
            '^lib/{{}}.dart': 'lib/gen/{{}}.g.dart'
      freezed:
        options:
          build_extensions:
            '^lib/{{}}.dart': 'lib/gen/{{}}.freezed.dart'

After that all .g.dart and .freezed.dart files are saved into "/lib/gen/..." root folder. I want to place all *.mapper.g.dart files there too.

smotastic commented 2 years ago

Fixed with #60