[英]How run flutter 'packages pub run build_runner build' with debug mode in intellij idea?
I want to put break point on my generator code, but I don't know how to run the command on the debug mode.我想在我的生成器代码上设置断点,但我不知道如何在调试模式下运行命令。
I wrote generator using source_gen
and build_runner
我使用
source_gen
和build_runner
编写了生成器
class MyGenerator extends GeneratorForAnnotation<Todo> {
@override
FutureOr<String> generateForAnnotatedElement(
Element element, ConstantReader annotation, BuildStep buildStep) {
return "// Hey! Annotation found!";
}
}
Ivan's answer worked for me, but every time I changed a file that was using an annotation - the build process outputted:伊万的回答对我有用,但每次我更改使用注释的文件时 - 构建过程都会输出:
[SEVERE] Terminating builds due to build script update
[INFO] Terminating. No further builds will be scheduled
and then renamed the build script itself from build.dart
to build.dart.cached
, and then exit with code 75.然后将构建脚本本身从
build.dart
重命名为build.dart.cached
,然后以代码 75 退出。
After digging through the build_runner
code, I discovered that this behavior can be mitigated by using the following Program Arguments:在挖掘
build_runner
代码后,我发现可以通过使用以下程序 Arguments 来缓解这种行为:
serve --skip-build-script-check
(ie instead of just serve
as Ivan suggested). (即不只是像伊万建议的那样
serve
)。
There may be some negative consequences;可能会有一些负面后果; in the
build_runner
source code, in options.dart
, I saw this:在
build_runner
源代码的options.dart
中,我看到了这个:
// For testing only, skips the build script updates check.
bool skipBuildScriptCheck;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.