json_serializable.dart
json_serializable.dart copied to clipboard
Code generator build successfully but with 0 outputs and 0 actions
Versions
Content of my pubspec.yaml
:
name: hello_world
dependencies:
build_runner: ^2.1.8
characters: ^1.2.0
json_annotation: ^4.4.0
json_serializable: ^6.1.5
environment:
sdk: '>=2.16.0 <3.0.0'
Verbose
I've executed build_runner clean
previously, and here's what I see when I run dart run build_runner build --verbose
$ dart run build_runner build --verbose
[INFO] Entrypoint:Generating build script...
[INFO] Entrypoint:Generating build script completed, took 393ms
[INFO] Bootstrap:Precompiling build script......
[INFO] Bootstrap:Precompiling build script... completed, took 6.1s
[FINE] Bootstrap:Core package locations file does not exist
[INFO] BuildDefinition:Initializing inputs
[INFO] BuildDefinition:Building new asset graph...
[INFO] BuildDefinition:Building new asset graph completed, took 737ms
[INFO] BuildDefinition:Checking for unexpected pre-existing outputs....
[INFO] BuildDefinition:Checking for unexpected pre-existing outputs. completed, took 1ms
[INFO] Build:Running build...
[INFO] Build:Running build completed, took 7ms
[INFO] Build:Caching finalized dependency graph...
[INFO] Build:Caching finalized dependency graph completed, took 30ms
[INFO] Build:Succeeded after 47ms with 0 outputs (0 actions)
Project structure
I want to generate example.g.dart
for the file example.dart
, and here is the content of example.dart
(I completely copied it from https://pub.dev/packages/json_serializable)
import 'package:json_annotation/json_annotation.dart';
part 'example.g.dart';
@JsonSerializable()
class Person {
final String firstName, lastName;
final DateTime? dateOfBirth;
Person({required this.firstName, required this.lastName, this.dateOfBirth});
factory Person.fromJson(Map<String, dynamic> json) => _$PersonFromJson(json);
Map<String, dynamic> toJson() => _$PersonToJson(this);
}
I created this project by using IntelliJ IDEA
with Dart plugin installed, and selected the temple named Console Application
, but apparently this template doesn't work properly. So I created another new project by using the command dart create -t console-full another_dart_app
, added JsonSerializable
annotation for expected class and run the build_runner build
again, I don't know why but it works.