I have made a SharedPartBuilder that generates new class annotated with @JsonSerializable(). How can I configure json_serializable to run over .part file generated by my builder before all .part files are combined into one .g.dart?
Inside build.yaml, I have tried adding to my builder
runs_before: ["json_serializable"] and
applies_builders: ["json_serializable"] or
applies_builders: ["source_gen|combining_builder", "json_serializable"] all without success.
EDIT: It seems this is not possible when using SharedPartBuilder.
No
SharedPartBuilderwill be able to resolve the Dart code emitted by anotherSharedPartBuilder. In order for emitted code to be used with theResolverby later build steps, it must write to a.dartfile directly, and should be a different file extension than.g.dart.https://github.com/dart-lang/build/blob/master/docs/builder_author_faq.md
This is not possible when using
SharedPartBuilder.To make it work, I changed my
SharedPartBuildertoPartBuilderand setgeneratedExtensionto end with.dart.In
build.yamlI changed frombuild_to: cachetobuild_to: source.I can comment out
applies_builders ...and keep justruns_before: ["json_serializable"]and it still works.