运行什么来代替 flutter 包 pub run build_runner build --delete-conflicting-outputs

问题描述 投票:0回答:1

我的 Flutter 应用程序出于多种原因需要生成代码,例如用于测试的模拟生成,或者 Floor 和 Isar 持久性后端都需要生成。我通过执行

flutter packages pub run build_runner build --delete-conflicting-outputs
来实现这一点。我收到有关该命令已被弃用的消息。但是我想知道我应该运行什么命令。

目前我正在使用:

$ flutter packages pub run build_runner build --delete-conflicting-outputs
Deprecated. Use `dart run` instead.
Building package executable... (7.3s)
Built build_runner:build_runner.
[INFO] Generating build script completed, took 436ms
[INFO] Reading cached asset graph completed, took 227ms
[INFO] Checking for updates since last build completed, took 957ms
[WARNING] No actions completed for 18.2s, waiting on:
  - isar_generator on test/infer_sport_from_characteristics_id_test.dart
  - isar_generator on test/runn_rsc_test.dart
  - isar_generator on test/fitness_equipment_start_stop_workout_test.dart
  - isar_generator on test/fitness_equipment_process_record_test.dart
  - isar_generator on test/heart_rate_monitor_sensor_test.dart
  .. and 9 more

[INFO] Running build completed, took 29.4s
[INFO] Caching finalized dependency graph completed, took 117ms
[INFO] Succeeded after 29.6s with 15 outputs (97 actions)

这总是会重新生成文件。

第一次尝试:

$ dart run build_runner build --delete-conflicting-outputs
[INFO] Generating build script completed, took 427ms
[INFO] Reading cached asset graph completed, took 225ms
[INFO] Checking for updates since last build completed, took 979ms
[INFO] Running build completed, took 43ms
[INFO] Caching finalized dependency graph completed, took 137ms
[INFO] Succeeded after 189ms with 0 outputs (0 actions)

问题是这不会重新生成任何文件。没有布埃诺。

第二次尝试:

$ dart packages pub run build_runner build --delete-conflicting-outputs
Could not find a command named "packages".

Did you mean one of these?
  pub


Usage: dart <command|dart-file> [arguments]

Global options:
-v, --verbose               Show additional command output.
    --version               Print the Dart SDK version.
    --enable-analytics      Enable analytics.
    --disable-analytics     Disable analytics.
    --suppress-analytics    Disallow analytics for this `dart *` run without changing the analytics configuration.
-h, --help                  Print this usage information.

Available commands:
  analyze    Analyze Dart code in a directory.
  compile    Compile Dart to various formats.
  create     Create a new Dart project.
  devtools   Open DevTools (optionally connecting to an existing application).
  doc        Generate API documentation for Dart projects.
  fix        Apply automated fixes to Dart source code.
  format     Idiomatically format Dart source code.
  info       Show diagnostic information about the installed tooling.
  pub        Work with packages.
  run        Run a Dart program.
  test       Run tests for a project.

Run "dart help <command>" for more information about a command.
See https://dart.dev/tools/dart-tool for detailed documentation.

我正在使用测试版频道和最新的

build_runner
(2.4.6)。

$ flutter doctor
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel beta, 3.13.0-0.3.pre, on Devuan GNU/Linux 6 (excalibur/ceres) 6.4.0-2-amd64, locale en_US.UTF-8)
[✓] Android toolchain - develop for Android devices (Android SDK version 33.0.1)
[✓] Linux toolchain - develop for Linux desktop
[✓] Android Studio (version 2022.3)
[✓] VS Code (version 1.81.1)
[✓] Connected device (2 available)
[✓] Network resources

我查看了其他一些 SO 条目,但到目前为止我没有任何错误,并且我的 CI/CD 可以工作,但是我想迁移直到命令完全弃用。

flutter dart code-generation build-runner
1个回答
0
投票

您可以尝试这些命令。

专业提示,根据您的情况将这些别名添加到您的

~/.bashrc
~/.zshrc
外壳。

alias flc='flutter clean'
alias flr='flutter run'
alias brw='flutter pub run build_runner watch --delete-conflicting-outputs'
alias brb='flutter pub run build_runner build --delete-conflicting-outputs'
alias brc='flutter pub run build_runner clean'
© www.soinside.com 2019 - 2024. All rights reserved.