我有以下 PostProcessBuilder
class MoveBuilder extends PostProcessBuilder {
@override
Iterable<String> get inputExtensions => ['.g.dart'];
MoveModelBuilder() ;
@override
Future<void> build(PostProcessBuildStep buildStep) async {
log.info('MOVE THE FILE');
}
}
以及以下顶级函数
PostProcessBuilder moveSomething(BuilderOptions options) {
return MoveModelBuilder();
}
在我的生成器包中使用以下构建配置
builders:
my_builder:
import: "package:my_package/src/builders/builders.dart"
builder_factories: ["buildSomething"]
build_extensions: {'.dart': ['.g.dart']}
auto_apply: none
build_to: source
applies_builders:
- my_package|move_builder
post_process_builders:
move_builder:
import: "package:my_package/src/builders/builders.dart"
builder_factory: moveSomething
在我使用此生成器的外部包中,我有以下构建 yaml
targets:
$default:
builders:
my_package|my_builder:
enabled: true
generate_for:
- lib/*/input_folder/*.dart
my_package|move_builder:
enabled: true
generate_for:
- lib/*/relative_output_folder/*.g.dart
但只有当我第一次运行构建运行程序命令时,MoveBuilder 才会被触发。似乎只有在此警告后才会触发
[警告] BuildDefinition:丢弃缓存的资源图,因为构建阶段已更改。这种情况最常见的原因是添加新的依赖项或更新依赖项。
因此,在重新初始化缓存的资产图之后。
我该怎么做才能让它在我的主构建器每次运行后运行?