Skip to content

Commit 85ac59f

Browse files
committed
Just warn (don't fail) when the json_annotation constraint looks wrong
Fixes #1011 Fixes #1014 Fixes #1020 Fixes #1025
1 parent c6d3490 commit 85ac59f

File tree

3 files changed

+6
-16
lines changed

3 files changed

+6
-16
lines changed

json_serializable/CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
- Support `JsonKey.readValue` to allow customized reading of values from source
44
JSON map objects.
5+
- The check to make sure there is a correctly constrained dependency on
6+
`package:json_annotation` is now a warning and doesn't fail the build.
57
- Require `json_annotation` `'>=4.4.0 <4.5.0'`.
68

79
## 6.0.1

json_serializable/lib/src/check_dependencies.dart

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ Future<void> _validatePubspec(bool production, BuildStep buildStep) async {
5151

5252
if (errorMessage == null) return;
5353

54-
throw BadPackageDependencyError(errorMessage);
54+
log.warning(errorMessage);
5555
}
5656

5757
String? _checkAnnotationConstraint(
@@ -124,13 +124,3 @@ class _OncePerBuild {
124124
}
125125
}
126126
}
127-
128-
/// Thrown when a pubspec dependency is missing or incorrectly specified.
129-
class BadPackageDependencyError extends Error {
130-
final String message;
131-
132-
BadPackageDependencyError(this.message);
133-
134-
@override
135-
String toString() => message;
136-
}

json_serializable/test/annotation_version_test.dart

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -172,10 +172,8 @@ class SomeClass{}
172172
}
173173

174174
expect(lines.toString(), contains('''
175-
[SEVERE] json_serializable:json_serializable on $sourceDirectory/sample.dart:
175+
[WARNING] json_serializable:json_serializable on $sourceDirectory/sample.dart:
176+
$message'''));
176177

177-
$message
178-
'''));
179-
180-
await proc.shouldExit(1);
178+
await proc.shouldExit(0);
181179
}

0 commit comments

Comments
 (0)