GetDutchie / brick

An intuitive way to work with persistent data in Dart

Home Page:https://getdutchie.github.io/brick/#/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Need to run build_runner twice for correct schema.g.dart generation

edgarbs1998 opened this issue · comments

For some reason, on my main project I need to always run the build_runner twice in order to my schema.g.dart include the part '<migration_file>';, there are no errors or warning on the log, and the generation order looks fine, according to the log the migration file is being generated before schema file.

It only happens when I am also using the following dependency: https://pub.dev/packages/flutter_gen_runner
I don't know if it is related to have more than one library using the build_runner, or if it is a specific issue from some of the libraries.

Initially mentioned this issue on #309 (comment), since I thought those were related, but does not look like so. You may have some clue on this situation.

I just created a new branch from my last example repository: https://github.com/edgarbs1998/brick_issue_309/tree/issue_312

First build_runner run:

flutter pub run build_runner build --delete-conflicting-outputs
[INFO] Generating build script... 
[INFO] Generating build script completed, took 176ms  
[INFO] Precompiling build script...... 
[INFO] Precompiling build script... completed, took 3.4s  
FlutterGen v5.1.0+1 Loading ... pubspec.yaml
 
[INFO] Initializing inputs 
[INFO] Building new asset graph... 
[INFO] Building new asset graph completed, took 389ms  [INFO] Checking for unexpected pre-existing outputs.... 
[INFO] Checking for unexpected pre-existing outputs. completed, took 0ms  
[INFO] Running build... 
[INFO] Generating SDK summary... 
[INFO] 1.0s elapsed, 0/1 actions completed. 
[INFO] 2.1s elapsed, 0/1 actions completed. 
[INFO] Generating SDK summary completed, took 2.2s  
[INFO] Generated note_adapter.g.dart (Note), took 51ms 
[INFO] Aggregating models and migrations... 
[INFO] Generated brick.g.dart, took 4ms 
[INFO] Generated new migration (db/20230104112318.migration.dart), took 4ms 
[INFO] Generated db/schema.g.dart, took 13ms 
Generated: lib/gen/assets.gen.dart 
FlutterGen finished. 
[INFO] Running build completed, took 3.1s  [INFO] Caching finalized dependency graph... 
[INFO] Caching finalized dependency graph completed, took 29ms  
[INFO] Succeeded after 3.2s with 6 outputs (25 actions)  

Second build_runner run:

flutter pub run build_runner build --delete-conflicting-outputs
[INFO] Generating build script... 
[INFO] Generating build script completed, took 208ms  
FlutterGen v5.1.0+1 Loading ... pubspec.yaml
 
[INFO] Initializing inputs 
[INFO] Reading cached asset graph... 
[INFO] Reading cached asset graph completed, took 31ms  
[INFO] Checking for updates since last build... 
[INFO] Checking for updates since last build completed, took 354ms  
[INFO] Running build... 
[INFO] 1.3s elapsed, 0/1 actions completed. 
[INFO] Aggregating models and migrations... 
[INFO] Generated brick.g.dart, took 6ms 
[INFO] Generated db/schema.g.dart, took 25ms 
[INFO] Running build completed, took 1.5s  [INFO] Caching finalized dependency graph... 
[INFO] Caching finalized dependency graph completed, took 17ms  
[INFO] Succeeded after 1.5s with 4 outputs (10 actions)  
``

@edgarbs1998 Ah, this is a good bug. One I've been putting off for too long. This changed, coincidentally, from analyzer 2 to analyzer 3. I'll be looking into a fix real soon. In the meantime, I thank you for your patience to run build_runner twice