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

How to use with --build-filter? #1054

Closed
duzenko opened this issue Dec 1, 2021 · 9 comments
Closed

How to use with --build-filter? #1054

duzenko opened this issue Dec 1, 2021 · 9 comments

Comments

@duzenko
Copy link

duzenko commented Dec 1, 2021

A few version back I could limit the scope of the generation to a particular folder with

flutter pub run build_runner build --delete-conflicting-outputs --build-filter 'lib/models/feed/*.dart'

Now whatever I try it either deletes generated files in other folders, complains about conflicts, or processes all folders
Please advise

@kevmoo
Copy link
Collaborator

kevmoo commented Dec 3, 2021

@jakemac53 ?

@jakemac53
Copy link
Collaborator

I would need to know more information, as far as I am aware this option should still work fine.

Now whatever I try it either deletes generated files in other folders

This is what --delete-conflicting-outputs does - if you are cloning a repo fresh and you check generated files into git (fine to do), you will want to regenerate all the files the first time most likely.

complains about conflicts

This doesn't happen if you pass --delete-conflicting-outputs right? Or are you getting issues even with that?

or processes all folders

Note that any file which is transitively imported by any input in your filter will also be generated (its a transitive input). So that can cause more things to be built than you might intend.

@duzenko
Copy link
Author

duzenko commented Dec 4, 2021

Could be a one time glitch then
I quickly retried once again with a folder filter and it did not delete or complain about anything but nothing was changed too
I will reopen if it plays up again

@duzenko duzenko closed this as completed Dec 4, 2021
@duzenko
Copy link
Author

duzenko commented Dec 31, 2021

Occurred again. This command
flutter pub run build_runner build --delete-conflicting-outputs --build-filter 'lib/api/domains/user/*.dart'
while generating the code in the 'lib/api/domains/user' folder, deletes generated files in all other folders

@duzenko duzenko reopened this Dec 31, 2021
@jakemac53
Copy link
Collaborator

Yes, --delete-conflicting-outputs is a global option - it doesn't only apply to the outputs built as a part of the --build-filter. This is something done before the build even starts.

When using that option you would need to do a full build (without --build-filter) first, or else the other files won't be generated.

@duzenko
Copy link
Author

duzenko commented Jan 4, 2022

What is the meaning of --build-filter then if it's not supposed to be producing adequate results with and without delete conflicting outputs?
Anyway, my issue is that sometimes it works, and then sometimes it does not. Today it worked in another folder.

@jakemac53
Copy link
Collaborator

What is the meaning of --build-filter then if it's not supposed to be producing adequate results with and without delete conflicting outputs?

The job of --build-filter is just to build the specified files (and anything required to build those). It is up to you to ensure that build is sufficient.

The --delete-conflicting-outputs flag should only be necessary for the very first build after downloading a project from github, or any time after deleting your .dart_tool/build directory. It fully purges all source files that conflict with files the build expects to generate.

So yes using these two together all the time may result in an incomplete project - because one deletes all source files that overlap with expected outputs of the build, and the other only rebuilds some of them, as requested.

@duzenko
Copy link
Author

duzenko commented Jan 5, 2022

@jakemac53 please clarify how we can regenerate a subset of generated files (e.g. in a given subfolder) when only one or few files change without regenerating the entire project.

@jakemac53
Copy link
Collaborator

See dart-lang/build#3233 which moves docs for the feature from the changelog to a more discoverable place in our docs directory.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants