From 43579da76a9fe9b211a0d3b9fe9caf667baa8dc7 Mon Sep 17 00:00:00 2001 From: Tobe O Date: Fri, 2 Mar 2018 14:49:47 -0500 Subject: [PATCH] build.yaml --- angel_serialize_generator/build.yaml | 23 +++++++++++++++++++ .../lib/angel_serialize_generator.dart | 21 ++++++++++++++--- angel_serialize_generator/pubspec.yaml | 1 + 3 files changed, 42 insertions(+), 3 deletions(-) create mode 100644 angel_serialize_generator/build.yaml diff --git a/angel_serialize_generator/build.yaml b/angel_serialize_generator/build.yaml new file mode 100644 index 00000000..a1e57687 --- /dev/null +++ b/angel_serialize_generator/build.yaml @@ -0,0 +1,23 @@ +targets: + _json_model_builder: + _serializer_builder: + +builders: + json_model: + target: "_json_model_builder" + import: "package:angel_serialize_generator/angel_serialize_generator.dart" + builder_factories: + - jsonModel + auto_apply: dependents + build_extensions: + .dart: + - ".g.dart" + serializer: + target: "_serializer_builder" + import: "package:angel_serialize_generator/angel_serialize_generator.dart" + builder_factories: + - serializeGenerator + auto_apply: dependents + build_extensions: + .dart: + - ".serializer.g.dart" \ No newline at end of file diff --git a/angel_serialize_generator/lib/angel_serialize_generator.dart b/angel_serialize_generator/lib/angel_serialize_generator.dart index 3ea115d1..82191a7c 100644 --- a/angel_serialize_generator/lib/angel_serialize_generator.dart +++ b/angel_serialize_generator/lib/angel_serialize_generator.dart @@ -10,9 +10,25 @@ import 'package:recase/recase.dart'; import 'package:source_gen/source_gen.dart' hide LibraryBuilder; import 'build_context.dart'; import 'context.dart'; + part 'model.dart'; + part 'serialize.dart'; +Builder jsonModelBuilder(_) { + return new PartBuilder( + const [const JsonModelGenerator()], + generatedExtension: '.g.dart', + ); +} + +Builder serializerBuilder(_) { + return new PartBuilder( + const [const SerializerGenerator()], + generatedExtension: '.g.dart', + ); +} + /// Converts a [DartType] to a [TypeReference]. TypeReference convertTypeReference(DartType t) { return new TypeReference((b) { @@ -28,8 +44,7 @@ TypeReference convertTypeReference(DartType t) { bool isModelClass(DartType t) { if (t == null) return false; - if (serializableTypeChecker.hasAnnotationOf(t.element)) - return true; + if (serializableTypeChecker.hasAnnotationOf(t.element)) return true; if (t is InterfaceType) { return isModelClass(t.superclass); @@ -43,4 +58,4 @@ bool isMapToModelType(InterfaceType t) { return t.name == 'Map' && t.typeArguments.length == 2 && isModelClass(t.typeArguments[1]); -} \ No newline at end of file +} diff --git a/angel_serialize_generator/pubspec.yaml b/angel_serialize_generator/pubspec.yaml index a98b9d50..026938e2 100644 --- a/angel_serialize_generator/pubspec.yaml +++ b/angel_serialize_generator/pubspec.yaml @@ -8,6 +8,7 @@ environment: dependencies: angel_serialize: path: ../angel_serialize + build_config: ">=0.0.0 <2.0.0" code_builder: ^2.0.0 id: ^1.0.0 recase: ^1.0.0