-
Notifications
You must be signed in to change notification settings - Fork 213
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[build_runner] execute builder on only a single file #2928
Comments
See #2815, and comments about the One thing I just remembered which is not captured there is I believe that build to source generators always do run regardless of that argument. Not for a technical reason but because those files ship with packages on pub and for safety we wanted to ensure they were always up to date. We could revisit that decision, or possibly consider an override flag for that behavior, etc. As a longer term solution here specifying which files the builder needs to run on is almost certainly going to give you the biggest bang for your buck, see my comment here #2861 (comment). |
@jakemac53 Thanks for the response. I didn't know about The longest it took for us to run the build runner was almost 16 minutes. :S and that for adding a new field to an enum :S It would be really amazing if we could simply run the build_runner for only a single file :/ Hope that gets added soon :D |
@lunaticcoding if you are seeing build times that long, then configuring your build to only run on the more specific files that you need it to is definitely worth while. For small/medium sized projects this is less important, but it becomes important for large apps. If you want help with that let me know. With regards to building single files note that it will still have to build any transitively imported file of the file you want to build, so depending on the structure of your app this may or may not help that much. As a common example, if your package libraries all import a convenience library which exports everything else from the package, then that means it also imports all other generated files in your package and thus they will all be generated when building any of them. |
@jakemac53 oh I see. okay, that makes sense (still would be awesome if we could say we don't care about the imports - but I see as to how this is a bigger change). How would we go about limiting the scope? I would really appreciate the help :D |
You can create a
The builder key is the identifier for the builder you are configuring, this is of the format |
@jakemac53 Thank you :D this is already a huge improvement |
Glad to hear that helped! I am going to close this issue for now, as we do support building specific outputs (which includes all their inputs...). If you have a case where that feature isn't working as intended please do file an issue about that. |
@jakemac53 one more question :) Is there a way to add a single line at the beginning of every file created by a certain builder? |
Hello, can you point to some examples of using build_runner targeting only 1 file, please? I tried my best to use the --build-filter to target a single file but had no success in doing so. I am probably missing something. Here is everything I tried so far, without success:
On the other hand, I successfully used the --build-filter option to target specific files type under a folder with: It is good enough but since since it seems possible to target a single file I would love to know how pleae. |
@hbock-42 any relative path under your package should work, but you need to specify the outputs you are trying to build. So probably |
Damn thank you, I missed the crucial point that the filter needs to target the output file and not the original file! |
@jakemac53 @hbock-42 Please help..... I am fucking got buld_runnfer just partly gened files, these files in data model all gened, but these file with database dao not gen... Why?? I tried many times, only these dao and database gen not gen.... |
You can use --build-filter="lib/*.dart" Example: |
Thank you @hbock-42 and @jakemac53 |
this command can execute builder on only a single file
|
This definitely doesn't work. I am executing the build runner on a single file called What happens is, that STILL |
This is a simple result of the hermetic build guarantees provided by the build system.
We do not allow things to exist in an inconsistent state, if it exists on disk it is guaranteed to be up to date (to the extent possible). |
I don't know if this is already possible but I could not find it in the documentation.
We have quite a large codebase making the builder take a very long time to run. Often we only changed a single file and would like to have a way to have the builder only recreate that single file. Is this already possible and if not is it feasible to implement for you guys or is there already a specific reason why this is not possible.
Thank you in advance and cheers :D
For general questions consider using Stack Overflow instead:
https://stackoverflow.com/questions/tagged/dart
Also consider our Gitter channel for light-weight/quick discussions:
https://gitter.im/dart-lang/build
The text was updated successfully, but these errors were encountered: