Skip to content

Commit 89e9642

Browse files
authored
example: update to json_serializable 0.3.0 (#88)
Removed 1 dev dependency 12 lines from tool/build_actions.dart
1 parent ca11c88 commit 89e9642

File tree

4 files changed

+16
-30
lines changed

4 files changed

+16
-30
lines changed

example/README.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,11 @@ dependencies to your `pubspec.yaml`.
33

44
```yaml
55
dependencies:
6-
json_annotation: ^0.2.1
6+
json_annotation: ^0.2.2
77

88
dev_dependencies:
99
build_runner: ^0.6.1
10-
json_serializable: ^0.2.5
11-
source_gen: ^0.7.2+1
10+
json_serializable: ^0.3.0
1211
```
1312
1413
Next, create the scripts to run code generation. The [`tool`][tool] directory

example/pubspec.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,12 @@ environment:
55
sdk: '>=1.20.1 <2.0.0'
66

77
dependencies:
8-
json_annotation: ^0.2.1
8+
json_annotation: ^0.2.2
99

1010
dev_dependencies:
1111
build_runner: ^0.6.1
12-
json_serializable: ^0.2.5
13-
source_gen: ^0.7.2+1
12+
json_serializable: ^0.3.0
1413

15-
# A great Dart testing package, but not required to use `json_serializable`.
14+
# Used by tests. Not required to use `json_serializable`.
15+
path: ^1.5.1
1616
test: ^0.12.29

example/test/readme_test.dart

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,9 @@ void _expect(String fileName) {
2020

2121
final _pubspecContent = r'''
2222
dependencies:
23-
json_annotation: ^0.2.1
23+
json_annotation: ^0.2.2
2424
2525
dev_dependencies:
2626
build_runner: ^0.6.1
27-
json_serializable: ^0.2.5
28-
source_gen: ^0.7.2+1
27+
json_serializable: ^0.3.0
2928
''';

example/tool/build_actions.dart

Lines changed: 8 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -5,28 +5,14 @@
55
/// Defines [BuildAction]
66
import 'package:build_runner/build_runner.dart';
77

8-
/// Defines [JsonSerializableGenerator] and [JsonLiteralGenerator]
9-
import 'package:json_serializable/generators.dart';
10-
11-
/// Defines [PartBuilder]
12-
import 'package:source_gen/source_gen.dart';
8+
/// Defines [jsonPartBuilder]
9+
import 'package:json_serializable/json_serializable.dart';
1310

1411
/// The list of [BuildAction]s used by `build.dart` and `watch.dart` to
1512
/// generate source code for this package.
1613
List<BuildAction> get buildActions => [
1714
new BuildAction(
18-
// `PartBuilder` is a `Builder` defined by `package:source_gen` for
19-
// generating Dart "part" files (.g.dart) given a set of generators.
20-
new PartBuilder(const [
21-
// Uses `@JsonSerializable()` annotations in source files to create
22-
// helpers to support to/from JSON.
23-
24-
const JsonSerializableGenerator(),
25-
26-
// Uses @JsonLiteral('...') annotations in source files to create
27-
// Dart literals for the provided JSON file.
28-
const JsonLiteralGenerator()
29-
], header: _copyrightContent),
15+
jsonPartBuilder(header: _copyrightContent),
3016

3117
// The name of the current package
3218
'example',
@@ -38,11 +24,13 @@ List<BuildAction> get buildActions => [
3824
),
3925
];
4026

41-
/// Used in the `header` argument to the [PartBuilder] constructor to add the
42-
/// standard copyright notice to all generated files.
27+
/// Used in the `header` argument to the [jsonPartBuilder] constructor to add
28+
/// the standard copyright notice to all generated files.
4329
final _copyrightContent =
4430
'''// Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file
4531
// for details. All rights reserved. Use of this source code is governed by a
4632
// BSD-style license that can be found in the LICENSE file.
4733
48-
$defaultFileHeader''';
34+
// GENERATED CODE - DO NOT MODIFY BY HAND
35+
36+
''';

0 commit comments

Comments
 (0)