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 'package:source_gen/source_gen.dart' hide LibraryBuilder;
|
||||||
import 'build_context.dart';
|
import 'build_context.dart';
|
||||||
import 'context.dart';
|
import 'context.dart';
|
||||||
|
|
||||||
part 'model.dart';
|
part 'model.dart';
|
||||||
|
|
||||||
part 'serialize.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].
|
/// Converts a [DartType] to a [TypeReference].
|
||||||
TypeReference convertTypeReference(DartType t) {
|
TypeReference convertTypeReference(DartType t) {
|
||||||
return new TypeReference((b) {
|
return new TypeReference((b) {
|
||||||
|
@ -28,8 +44,7 @@ TypeReference convertTypeReference(DartType t) {
|
||||||
bool isModelClass(DartType t) {
|
bool isModelClass(DartType t) {
|
||||||
if (t == null) return false;
|
if (t == null) return false;
|
||||||
|
|
||||||
if (serializableTypeChecker.hasAnnotationOf(t.element))
|
if (serializableTypeChecker.hasAnnotationOf(t.element)) return true;
|
||||||
return true;
|
|
||||||
|
|
||||||
if (t is InterfaceType) {
|
if (t is InterfaceType) {
|
||||||
return isModelClass(t.superclass);
|
return isModelClass(t.superclass);
|
||||||
|
@ -43,4 +58,4 @@ bool isMapToModelType(InterfaceType t) {
|
||||||
return t.name == 'Map' &&
|
return t.name == 'Map' &&
|
||||||
t.typeArguments.length == 2 &&
|
t.typeArguments.length == 2 &&
|
||||||
isModelClass(t.typeArguments[1]);
|
isModelClass(t.typeArguments[1]);
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,6 +8,7 @@ environment:
|
||||||
dependencies:
|
dependencies:
|
||||||
angel_serialize:
|
angel_serialize:
|
||||||
path: ../angel_serialize
|
path: ../angel_serialize
|
||||||
|
build_config: ">=0.0.0 <2.0.0"
|
||||||
code_builder: ^2.0.0
|
code_builder: ^2.0.0
|
||||||
id: ^1.0.0
|
id: ^1.0.0
|
||||||
recase: ^1.0.0
|
recase: ^1.0.0
|
||||||
|
|
Loading…
Reference in a new issue