build.yaml
This commit is contained in:
parent
e3b1dc86ba
commit
43579da76a
3 changed files with 42 additions and 3 deletions
23
angel_serialize_generator/build.yaml
Normal file
23
angel_serialize_generator/build.yaml
Normal file
|
@ -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"
|
|
@ -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);
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue