Open
Description
Description of the bug
If you empty your openapi generated folder and you have tests that rely on those generated files, mockito:mockBuilder won't be able to find these files during the first generation.
This typically occurs if you have a CI/CD flow with GitHub Actions/Gitlab Runner/Azure DevOps and so on.
Edge cases:
- If I run
flutter pub get
after the first round of failure and then I run the build runner a second time, the error won't occur anymore. - If u run
flutter pub get
after removing the test folder, the error doesn't occur. I also tried configuring a build.yaml file telling the openapi_generator to run before mockito:mockBuilder but it doesn't solve the problem.
Since I'm using FVM and I noticed there's a potential fix while updating the dependencies, I also tried to test this scenario against this PR without success.
I can't do these workarounds in my pipeline because they output a result code that makes my run fail.
Steps to reproduce
- Clone the project (in this case you have the folder empty excepts for the pubspec.yaml)
- Run flutter pub get
- Run build runner
[INFO] Generating build script completed, took 159ms
[INFO] Precompiling build script... completed, took 4.4s
[INFO] Building new asset graph completed, took 969ms
[INFO] Checking for unexpected pre-existing outputs. completed, took 4ms
[INFO] Generating SDK summary completed, took 2.2s
[INFO] openapi_generator on lib/app.dart:
:::::::::::::::::::::::::::::::::::::::::::
:: Openapi generator for dart ::
:::::::::::::::::::::::::::::::::::::::::::
[WARNING] openapi_generator on lib/app.dart:
loadSpec - /home/angeloavv/FlutterProjects/blablabla/.dart_tool/openapi-generator-cache.json
[WARNING] openapi_generator on lib/app.dart:
loadSpec - openapi/blablabla.json
[INFO] openapi_generator on lib/app.dart:Loaded cached and current spec files.
[INFO] openapi_generator on lib/app.dart:Dirty Spec found. Running generation.
[INFO] openapi_generator on lib/app.dart:Running following command to generate openapi client - [ generate -o=submodules/openapi -i=openapi/blablabla.json -g=dart-dio ]
[INFO] openapi_generator on lib/app.dart:Openapi generator completed successfully.
[INFO] openapi_generator on lib/app.dart:Installing dependencies with generated source. flutter pub get
[INFO] openapi_generator on lib/app.dart:Install completed successfully.
[INFO] openapi_generator on lib/app.dart:Running source code generation.
[INFO] openapi_generator on lib/app.dart:flutter pub run build_runner build --delete-conflicting-outputs
[WARNING] No actions completed for 15.0s, waiting on:
- openapi_generator on lib/app.dart
[INFO] openapi_generator on lib/app.dart:Codegen completed successfully.
[INFO] openapi_generator on lib/app.dart:Sources generated successfully.
[WARNING] openapi_generator on lib/app.dart:
loadSpec - openapi/blablabla.json
[INFO] openapi_generator on lib/app.dart:Successfully cached spec changes.
[INFO] openapi_generator on lib/app.dart:Successfully formatted code.
[INFO] openapi_generator on lib/app.dart:Found generated timestamp. Updating with 2024-03-01T09:44:37.654917
[SEVERE] mockito:mockBuilder on test/services/network/test_model_service/test_model_service_test.dart:
Invalid @GenerateMocks annotation: The GenerateMocks "classes" argument is missing, includes an unknown type, or includes an extension
[SEVERE] mockito:mockBuilder on test/services/sync_merge/news_item_event_types/news_item_event_types_service_test.dart:
Invalid @GenerateMocks annotation: The GenerateMocks "classes" argument is missing, includes an unknown type, or includes an extension
[SEVERE] mockito:mockBuilder on test/services/sync_merge/news_item_log_events/news_item_log_events_service_test.dart:
Invalid @GenerateMocks annotation: The GenerateMocks "classes" argument is missing, includes an unknown type, or includes an extension
[SEVERE] mockito:mockBuilder on test/services/sync_merge/news_items/news_items_service_test.dart:
Invalid @GenerateMocks annotation: The GenerateMocks "classes" argument is missing, includes an unknown type, or includes an extension
[SEVERE] mockito:mockBuilder on test/services/sync_merge/news_item_network/news_item_network_service_test.dart:
Invalid @GenerateMocks annotation: The GenerateMocks "classes" argument is missing, includes an unknown type, or includes an extension
[WARNING] auto_route_generator on lib/pages/article/article_page.dart:
WARNING => Because [ArticlePage] has required parameters (source) that can not be parsed from path,
@PathParam() and @QueryParam() annotations will be ignored.
[INFO] Running build completed, took 32.2s
[INFO] Caching finalized dependency graph completed, took 162ms
[SEVERE] Failed after 32.3s
Expected behavior
[INFO] Generating build script completed, took 161ms
[WARNING] Throwing away cached asset graph because the build phases have changed. This most commonly would happen as a result of adding a new dependency or updating your dependencies.
[WARNING] Throwing away cached asset graph because the language version of some package(s) changed. This would most commonly happen when updating dependencies or changing your min sdk constraint.
[INFO] Cleaning up outputs from previous builds. completed, took 22ms
[INFO] Generating build script completed, took 50ms
[WARNING] Invalidated precompiled build script due to missing asset graph.
[INFO] Precompiling build script... completed, took 4.9s
[INFO] Building new asset graph completed, took 990ms
[INFO] Checking for unexpected pre-existing outputs. completed, took 0ms
[INFO] openapi_generator on lib/app.dart:
:::::::::::::::::::::::::::::::::::::::::::
:: Openapi generator for dart ::
:::::::::::::::::::::::::::::::::::::::::::
[WARNING] openapi_generator on lib/app.dart:
loadSpec - /home/angeloavv/FlutterProjects/blablabla/.dart_tool/openapi-generator-cache.json
[WARNING] openapi_generator on lib/app.dart:
loadSpec - openapi/blablabla.json
[INFO] openapi_generator on lib/app.dart:Loaded cached and current spec files.
[INFO] openapi_generator on lib/app.dart:No diff between versions, not running generator.
[INFO] openapi_generator on lib/app.dart:Successfully formatted code.
[INFO] openapi_generator on lib/app.dart:Found generated timestamp. Updating with 2024-03-01T09:42:36.749179
[WARNING] auto_route_generator on lib/pages/article/article_page.dart:
WARNING => Because [ArticlePage] has required parameters (source) that can not be parsed from path,
@PathParam() and @QueryParam() annotations will be ignored.
[INFO] Running build completed, took 15.4s
[INFO] Caching finalized dependency graph completed, took 171ms
[INFO] Succeeded after 15.6s with 598 outputs (3691 actions)
Logs
No response
Screenshots
No response
Platform
Linux
Library version
5.0.2
Flutter version
3.19.1
Flutter channel
stable
Additional context
No response