Skip to content
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

Add ability to always run #3561

Closed
Nexushunter opened this issue Aug 18, 2023 · 2 comments
Closed

Add ability to always run #3561

Nexushunter opened this issue Aug 18, 2023 · 2 comments
Labels
closed-not-planned Closed as we don't intend to take action on the reported issue

Comments

@Nexushunter
Copy link

  • Dart SDK Version (dart --version)
    Dart SDK version: 3.0.7 (stable) (Mon Jul 24 13:17:56 2023 +0000) on "linux_x64"

  • What package(s) from this repo you are using, and the version (i.e. build_runner 0.7.12)
    2.4.6

  • What builder(s) you are using (or writing yourself).

We have a builder wrapped around the OpenAPI generator (see this PR) and we are looking to be able to run the generator when there is a change to the underlying spec. While the Dart defined configuration isn't being changed the underlying spec is. This would be akin to the node wrapper for the Openapi-generator, but for those who are used to using a dart based environment.

  • Whether you are using Windows, MacOSX, or Linux (if applicable)

Linux

  • Whether you are using Chrome, Safari, Firefox, Edge (if applicable)

N/A

  • Any other packages or constraints we should know about
    The user shouldn't need to leave the ecosystem they are already in. Also the openapi-generator-cli does the actual generation for us. We are effectively looking to be able to allow for a rerun when the asset graph hasn't changed.

My thoughts to solve this would be to be able to add a build option like build_to: cache but it be alwaysRun: <true|false> or something similar.

If this is already achievable would you mind pointing me to the documentation? I have not been able to find any in this vain.

@Nexushunter
Copy link
Author

Nexushunter commented Aug 18, 2023

Currently to work around this issue I need to run: rm .dart_tool/build/**/asset_graph.json && flutter|dart pub run build_runner build which feels risky to do as this could cause issues where multiple builders are present. The other solution we chose, but is definitely a workaround, is to inject a comment after the generation is complete to invalidate the build cache; which feels really hacky.

@jakemac53
Copy link
Contributor

I understand why you want this, but it generally isn't compatible with how this build system works. Any sort of builder which would always require re-running, must be violating a fundamental contract of builders (ie: using dart:io directly to reach outside the package directory or maybe to the internet instead of using the BuildStep apis).

My suggestion would be to create a separate tool that you run which will copy whatever external resources you need into an actual file on disk in some location which you can read through the BuildStep APIs. That tool might also kick off a build right after doing that if you want to always only run a single command.

So for example you could have a script at tool/build.dart which does some resource copy and then uses Process.run to run a build_runner command (possibly forwarding all arguments from the current process).

We have discussed in the past some more formal API for "external resources" which could simplify/formalize some of this, but we don't have one for now.

@jakemac53 jakemac53 added the closed-not-planned Closed as we don't intend to take action on the reported issue label Aug 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
closed-not-planned Closed as we don't intend to take action on the reported issue
Projects
None yet
Development

No branches or pull requests

2 participants