-
Notifications
You must be signed in to change notification settings - Fork 478
Precondition recipe to make a recipe run only once #6339
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
base: main
Are you sure you want to change the base?
Conversation
|
|
||
| @Override | ||
| public @Nullable Tree visit(@Nullable Tree tree, ExecutionContext ctx) { | ||
| for (Recipe recipe : ctx.getCycleDetails().getMadeChangesInThisCycle()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This way if the recipe doesn't make any changes it will still be re attempted.
The recipe stack is not public API of the RecipeRunCycle, if it were we could modify the stack to only contain a single instance of the recipe so it's ran exactly once.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the more typical desired state with this recipe is run once regardless of whether it made changes.
It is the case of something like removing unnecessary parentheses which might make changes as the result of other recipes that makes this behavior not desirable in every case. But opting in to the singleton-like recipe is an explicit indication of intent.
What's changed?
Introduce a recipe that can be used as precondition to prevent a recipe from running multiple times
What's your motivation?
Nested recipe cycles may make recipes significantly slower than they have to be
Checklist